ZQuest Classic Coverage Report


Directory: src/
File: src/zq/zquest.cpp
Date: 2025-11-27 06:33:24
Exec Total Coverage
Lines: 1969 13258 14.9%
Functions: 44 679 6.5%
Branches: 1112 9748 11.4%

Line Branch Exec Source
1 #include "allegro/gui.h"
2 #include "base/files.h"
3 #include "base/mapscr.h"
4 #include "dialog/edit_region.h"
5
6 #include <memory>
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <cstring>
10 #include <sstream>
11 #include <ctype.h>
12 #include <assert.h>
13 #include <time.h>
14 #include <vector>
15 #include <filesystem>
16 #include <base/new_menu.h>
17
18 #include "dialog/info_lister.h"
19 #include "zq/commands.h"
20 #include "zq/render_map_view.h"
21 #ifdef __APPLE__
22 // malloc.h is deprecated, but malloc also lives in stdlib
23 #include <stdlib.h>
24 #else
25 #include <malloc.h>
26 #endif
27
28 #include "zalleg/zalleg.h"
29 #include "base/qrs.h"
30 #include "base/dmap.h"
31 #include "base/msgstr.h"
32 #include "base/packfile.h"
33 #include "base/cpool.h"
34 #include "base/autocombo.h"
35 #include "base/render.h"
36 #include "base/version.h"
37 #include "zq/autocombo/autopattern_base.h"
38 #include "zq/autocombo/pattern_basic.h"
39 #include "zq/autocombo/pattern_flatmtn.h"
40 #include "zq/autocombo/pattern_fence.h"
41 #include "zq/autocombo/pattern_cakemtn.h"
42 #include "zq/autocombo/pattern_relational.h"
43 #include "zq/autocombo/pattern_dungeoncarve.h"
44 #include "zq/autocombo/pattern_dormtn.h"
45 #include "zq/autocombo/pattern_tiling.h"
46 #include "zq/autocombo/pattern_replace.h"
47 #include "zq/autocombo/pattern_denseforest.h"
48 #include "zq/autocombo/pattern_extend.h"
49 #include "zq/render_hotkeys.h"
50 #include "zq/render_minimap.h"
51 #include "zq/render_tooltip.h"
52 #include "base/misctypes.h"
53 #include "parser/Compiler.h"
54 #include "base/zc_alleg.h"
55 #include "particles.h"
56 #include "dialog/combopool.h"
57 #include "dialog/alert.h"
58 #include "dialog/alertfunc.h"
59 #include "zq/gui/edit_autocombo.h"
60
61 #include <al5_img.h>
62 #include <loadpng.h>
63 #include <fmt/format.h>
64
65 #include "dialog/cheat_codes.h"
66 #include "dialog/set_password.h"
67 #include "dialog/foodlg.h"
68 #include "dialog/quest_rules.h"
69 #include "dialog/script_rules.h"
70 #include "dialog/headerdlg.h"
71 #include "dialog/ffc_editor.h"
72 #include "dialog/screen_data.h"
73 #include "dialog/edit_dmap.h"
74 #include "dialog/compilezscript.h"
75 #include "dialog/screen_enemies.h"
76 #include "dialog/enemypattern.h"
77 #include "dialog/sfxdata.h"
78 #include "dialog/mapstyles.h"
79 #include "dialog/externs.h"
80
81 #include "base/gui.h"
82 #include "gui/jwin_a5.h"
83 #include "gui/jwin.h"
84 #include "zc_list_data.h"
85 #include "gui/editbox.h"
86 #include "zq/zq_misc.h"
87 #include "zq/zq_tiles.h" // tile and combo code
88
89 #include "zq/zquest.h"
90 #include "zq/ffasm.h"
91 #include "zq/render.h"
92
93 // the following are used by both zelda.cc and zquest.cc
94 #include "base/zdefs.h"
95 #include "base/qrs.h"
96 #include "tiles.h"
97 #include "base/colors.h"
98 #include "base/qst.h"
99 #include "base/zsys.h"
100 #include "base/zapp.h"
101 #include "base/process_management.h"
102 #include "play_midi.h"
103 #include "sound/zcmusic.h"
104
105 #include "midi.h"
106 #include "sprite.h"
107 #include "fontsdat.h"
108 #include "base/jwinfsel.h"
109 #include "zq/zq_class.h"
110 #include "subscr.h"
111 #include "zq/zq_subscr.h"
112 #include "zc/ffscript.h"
113 #include "gui/EditboxNew.h"
114 #include "sfx.h"
115 #include "zq/zq_custom.h" // custom items and guys
116 #include "zq/zq_strings.h"
117 #include "zq/questReport.h"
118 #include <fstream>
119 #include "drawing.h"
120 #include "zconsole/ConsoleLogger.h"
121 #include "colorname.h"
122 #include "zq/zq_hotkey.h"
123 #include "zq/package.h"
124 #include "zq/zq_files.h"
125 #include "music_playback.h"
126
127 //Windows mmemory tools
128 #ifdef _WIN32
129 #include <windows.h>
130 #include <stdio.h>
131 #include <psapi.h>
132 #pragma comment(lib, "psapi.lib") // Needed to avoid linker issues. -Z
133 #endif
134
135 #ifdef __EMSCRIPTEN__
136 #include <emscripten/emscripten.h>
137 #endif
138
139 #define MIDI_TRACK_BUFFER_SIZE 50
140 extern CConsoleLoggerEx parser_console;
141
142 using ZScript::disassembled_script_data;
143 void write_script(vector<shared_ptr<ZScript::Opcode>> const& zasm, string& dest,
144 bool commented, map<string,disassembled_script_data>* scr_meta_map);
145
146 namespace fs = std::filesystem;
147
148 #if defined(ALLEGRO_WINDOWS)
149 static const char *data_path_name = "win_data_path";
150 static const char *midi_path_name = "win_midi_path";
151 static const char *image_path_name = "win_image_path";
152 static const char *tmusic_path_name = "win_tmusic_path";
153 static const char *last_quest_name = "win_last_quest";
154 static const char *qtname_name = "win_qtname%d";
155 static const char *qtpath_name = "win_qtpath%d";
156 #elif defined(ALLEGRO_LINUX)
157 static const char *data_path_name = "linux_data_path";
158 static const char *midi_path_name = "linux_midi_path";
159 static const char *image_path_name = "linux_image_path";
160 static const char *tmusic_path_name = "linux_tmusic_path";
161 static const char *last_quest_name = "linux_last_quest";
162 static const char *qtname_name = "linux_qtname%d";
163 static const char *qtpath_name = "linux_qtpath%d";
164 #elif defined(__APPLE__)
165 static const char *data_path_name = "macosx_data_path";
166 static const char *midi_path_name = "macosx_midi_path";
167 static const char *image_path_name = "macosx_image_path";
168 static const char *tmusic_path_name = "macosx_tmusic_path";
169 static const char *last_quest_name = "macosx_last_quest";
170 static const char *qtname_name = "macosx_qtname%d";
171 static const char *qtpath_name = "macosx_qtpath%d";
172 #endif
173
174 #include "base/win32.h"
175
176 #include "zq/zq_init.h"
177 #include "zq/zq_doors.h"
178 #include "zq/zq_cset.h"
179 #include "zinfo.h"
180
181 #ifdef _MSC_VER
182 #include <crtdbg.h>
183
184 #endif
185
186 // MSVC fix
187 #if _MSC_VER >= 1900
188 FILE _iob[] = { *stdin, *stdout, *stderr };
189 extern "C" FILE * __cdecl __iob_func(void) { return _iob; }
190 #endif
191
192 extern byte monochrome_console;
193
194 #include "zconsole/ConsoleLogger.h"
195
196 extern CConsoleLoggerEx zscript_coloured_console;
197
198 uint8_t console_is_open = 0;
199 bool is_zq_replay_test = false;
200
201 #include "base/util.h"
202
203 #ifdef __EMSCRIPTEN__
204 #include "base/emscripten_utils.h"
205 #endif
206
207 using namespace util;
208
209 using std::vector;
210 using std::map;
211 using std::stringstream;
212
213 12 FFScript FFCore;
214
215 void load_size_poses();
216 void do_previewtext();
217 bool do_slots(vector<shared_ptr<ZScript::Opcode>> const& zasm,
218 map<string, disassembled_script_data> &scripts, int assign_mode);
219
220 bool cancelgetnum=false;
221
222 int32_t tooltip_timer=0, tooltip_maxtimer=30, tooltip_current_ffc=0;
223 int32_t combobrushoverride=-1;
224 ComboPosition mouse_combo_pos;
225
226 int32_t original_playing_field_offset=0;
227 12 int32_t playing_field_offset=original_playing_field_offset;
228 int32_t passive_subscreen_height=56;
229
230 bool disable_saving=false, OverwriteProtection;
231 bool halt=false;
232 bool show_sprites=true;
233 bool show_hitboxes = false;
234 bool zq_ignore_item_ownership = true;
235
236 // Used to find FFC script names
237 vector<string> asffcscripts;
238 vector<string> asglobalscripts;
239 vector<string> asitemscripts;
240 vector<string> asnpcscripts;
241 vector<string> aseweaponscripts;
242 vector<string> aslweaponscripts;
243 vector<string> asplayerscripts;
244 vector<string> asdmapscripts;
245 vector<string> asscreenscripts;
246 vector<string> asitemspritescripts;
247 vector<string> ascomboscripts;
248 vector<string> asgenericscripts;
249 vector<string> assubscreenscripts;
250
251 vector<string> ZQincludePaths;
252
253 int32_t CSET_SIZE = 16;
254 int32_t CSET_SHFT = 4;
255 //editbox_data temp_eb_data;
256 /*
257 #define CSET(x) ((x)<<CSET_SHFT)
258 #define csBOSS 14
259 */
260
261 /*
262 enum { m_block, m_coords, m_flags, m_guy, m_warp, m_misc, m_layers,
263 m_menucount };
264 */
265 void update_combo_cycling();
266 void update_freeform_combos();
267
268 /*
269 #define MAXMICE 14
270 #define MAXARROWS 8
271 #define SHADOW_DEPTH 2
272 */
273 int32_t coord_timer=0, coord_frame=0;
274 int32_t blackout_color, zq_screen_w, zq_screen_h;
275 int32_t draw_mode=0;
276
277 12 size_and_pos minimap;
278 12 size_and_pos real_minimap;
279
280 12 size_and_pos minimap_zoomed;
281 12 size_and_pos real_minimap_zoomed;
282
283 12 size_and_pos map_page_bar[9];
284 int32_t mappage_count = 9;
285
286 12 size_and_pos combolist[MAX_COMBO_COLS];
287 12 size_and_pos combolistscrollers[MAX_COMBO_COLS];
288 int32_t num_combo_cols = MAX_COMBO_COLS;
289
290 static bool zoom_in_btn_disabled;
291 static bool zoom_out_btn_disabled;
292 12 size_and_pos zoominbtn;
293 12 size_and_pos zoomoutbtn;
294 12 size_and_pos compactbtn;
295 12 size_and_pos mainbar;
296
297 12 size_and_pos screrrorpos;
298
299 12 size_and_pos comboaliaslist[MAX_COMBO_COLS];
300 12 size_and_pos comboalias_preview;
301 12 size_and_pos combopool_preview;
302 12 size_and_pos combopool_prevbtn;
303
304 12 size_and_pos combo_merge_btn;
305
306 12 size_and_pos combo_preview;
307 12 size_and_pos combo_preview2;
308 12 size_and_pos combo_preview_text1;
309 12 size_and_pos combo_preview_text2;
310 12 size_and_pos combolist_window;
311 12 size_and_pos drawmode_btn;
312 12 size_and_pos main_panel;
313 12 size_and_pos squares_panel;
314 12 size_and_pos preview_panel;
315 12 size_and_pos layer_panel;
316 12 size_and_pos preview_text;
317
318 12 size_and_pos favorites_window;
319 12 size_and_pos favorites_list;
320 12 size_and_pos favorites_x;
321 12 size_and_pos favorites_infobtn;
322 12 size_and_pos favorites_zoombtn;
323 12 size_and_pos favorites_pgleft;
324 12 size_and_pos favorites_pgright;
325
326 12 size_and_pos commands_window;
327 12 size_and_pos commands_list;
328 12 size_and_pos commands_x;
329 12 size_and_pos commands_infobtn;
330 12 size_and_pos commands_zoombtn;
331 12 size_and_pos commands_txt;
332
333 12 size_and_pos squarepanel_swap_btn;
334 12 size_and_pos squarepanel_up_btn;
335 12 size_and_pos squarepanel_down_btn;
336 12 size_and_pos itemsqr_pos;
337 12 size_and_pos flagsqr_pos;
338 12 size_and_pos stairsqr_pos;
339 12 size_and_pos warparrival_pos;
340 12 size_and_pos warpret_pos[4];
341 12 size_and_pos enemy_prev_pos;
342
343 12 size_and_pos txtoffs_single;
344 12 size_and_pos txtoffs_double_1;
345 12 size_and_pos txtoffs_double_2;
346 int32_t panel_align = 1;
347
348 int32_t command_buttonwidth = 88;
349 int32_t command_buttonheight = 19;
350
351 int32_t layerpanel_buttonwidth = 58;
352 int32_t layerpanel_buttonheight = 16;
353
354 int32_t layerpanel_checkbox_hei = 13;
355 int32_t layerpanel_checkbox_wid = 13;
356
357 int32_t favorite_combos[MAXFAVORITECOMBOS];
358 byte favorite_combo_modes[MAXFAVORITECOMBOS];
359 bool ShowFavoriteComboModes;
360 byte FavoriteComboPage;
361
362 char comboprev_buf[512] = {0};
363 char comboprev_buf2[512] = {0};
364 FONT* txfont;
365
366 int32_t mouse_scroll_h;
367
368 // 'mapscreen' refers to the area of the editor where the screen is drawn.
369 int32_t mapscreen_x, mapscreen_y, showedges, showallpanels;
370 // The scale of the entire mapscreen area. This varies based on compact/extended mode.
371 static int mapscreen_screenunit_scale;
372 // The scale of an individual screen being drawn. This is `mapscreen_screenunit_scale / Map.getViewSize()`.
373 static double mapscreen_single_scale;
374 // 4 is roughly the largest value where things render okay. Beyond that, our low bitmap resolution results in tons
375 // of downsampling. Let users go to 16 anyway.
376 static int mapscreen_num_screens_to_draw_max = 16;
377 // The valid layers for the current screen(s).
378 static bool mapscreen_valid_layers[6];
379
380 struct VisibleScreen
381 {
382 int dx, dy;
383 int xoff, yoff;
384 mapscr* scr;
385 int screen;
386 };
387 static std::vector<VisibleScreen> visible_screens;
388 static VisibleScreen* active_visible_screen = nullptr;
389
390 static void set_active_visible_screen(mapscr* scr)
391 {
392 active_visible_screen = nullptr;
393 for (auto& visible_screen : visible_screens)
394 {
395 if (visible_screen.scr == scr)
396 {
397 active_visible_screen = &visible_screen;
398 break;
399 }
400 }
401 }
402
403 static ComboPosition get_mapscreen_mouse_combo_pos()
404 {
405 int startxint = mapscreen_x+(showedges?int(16*mapscreen_single_scale):0);
406 int startyint = mapscreen_y+(showedges?int(16*mapscreen_single_scale):0);
407 int cx = (gui_mouse_x()-startxint)/(16*mapscreen_single_scale);
408 int cy = (gui_mouse_y()-startyint)/(16*mapscreen_single_scale);
409 return ComboPosition{cx, cy};
410 }
411
412 static void refresh_visible_screens()
413 {
414 int num_screens = Map.getViewSize();
415 int screen_width = mapscreenbmp->w * mapscreen_single_scale;
416 int screen_height = mapscreenbmp->h * mapscreen_single_scale;
417
418 visible_screens.clear();
419 for (int dx = 0; dx < num_screens; dx++)
420 {
421 for (int dy = 0; dy < num_screens; dy++)
422 {
423 int mx = Map.getViewScr()%16 + dx;
424 int my = Map.getViewScr()/16 + dy;
425 if (mx < 0 || mx >= 16 || my < 0 || my >= 9)
426 continue;
427
428 int screen = Map.getViewScr() + dx + dy * 16;
429 if (screen >= MAPSCRS)
430 continue;
431
432 mapscr* scr = Map.Scr(screen);
433 int offx = dx * screen_width;
434 int offy = dy * screen_height;
435 visible_screens.emplace_back(VisibleScreen{dx, dy, offx, offy, scr, screen});
436 }
437 }
438
439 for (int i = 0; i < 6; i++)
440 {
441 mapscreen_valid_layers[i] = false;
442 for (auto& vis_screen : visible_screens)
443 {
444 mapscreen_valid_layers[i] |= vis_screen.scr->layermap[i] > 0;
445 }
446 }
447 }
448
449 int32_t readsize, writesize;
450 bool fake_pack_writing=false;
451
452 int32_t showxypos_x;
453 int32_t showxypos_y;
454 int32_t showxypos_w;
455 int32_t showxypos_h;
456 int32_t showxypos_color;
457 int32_t showxypos_ffc=-1000;
458 bool showxypos_icon=false;
459
460 int32_t showxypos_cursor_x;
461 int32_t showxypos_cursor_y;
462 bool showxypos_cursor_icon=false;
463 int32_t showxypos_cursor_color;
464 bool showxypos_dummy = false;
465
466 bool canfill=true; //to prevent double-filling (which stops undos)
467 int32_t lens_hint_item[MAXITEMS][2]; //aclk, aframe
468 int32_t lens_hint_weapon[MAXWPNS][5]; //aclk, aframe, dir, x, y
469 //int32_t mode, switch_mode, orig_mode;
470 int32_t tempmode=GFX_AUTODETECT;
471 RGB_MAP* zq_rgb_table;
472 MIDI *song=NULL;
473 BITMAP *mapscreenbmp, *screen2, *mouse_bmp[MOUSE_BMP_MAX][4], *mouse_bmp_1x[MOUSE_BMP_MAX][4], *icon_bmp[ICON_BMP_MAX][4], *flag_bmp[16][4], *select_bmp[2], *dmapbmp_small, *dmapbmp_large;
474 BITMAP *arrow_bmp[MAXARROWS],*brushbmp, *brushscreen; //*brushshadowbmp;
475 byte *colordata=NULL, *trashbuf=NULL;
476 itemdata *itemsbuf;
477 wpndata *wpnsbuf;
478 comboclass *combo_class_buf;
479 guydata *guysbuf;
480 item_drop_object item_drop_sets[MAXITEMDROPSETS];
481 midi_info Midi_Info;
482 bool zq_showpal=false;
483 bool is_compact = false;
484
485 int pixeldb = 1;
486 int infobg = 1;
487 bool large_merged_combopane = false;
488 bool compact_merged_combopane = true;
489 bool large_zoomed_fav = false;
490 bool compact_zoomed_fav = true;
491 bool large_zoomed_cmd = false;
492 bool compact_zoomed_cmd = true;
493
494 bool compact_square_panels = false;
495 int compact_active_panel = 0;
496
497 int combo_col_scale = 1;
498
499 std::vector<std::shared_ptr<zasm_script>> zasm_scripts;
500 script_data *ffscripts[NUMSCRIPTFFC];
501 script_data *itemscripts[NUMSCRIPTITEM];
502 script_data *guyscripts[NUMSCRIPTGUYS];
503 script_data *lwpnscripts[NUMSCRIPTWEAPONS];
504 script_data *ewpnscripts[NUMSCRIPTWEAPONS];
505 script_data *globalscripts[NUMSCRIPTGLOBAL];
506 script_data *genericscripts[NUMSCRIPTSGENERIC];
507 script_data *playerscripts[NUMSCRIPTHERO];
508 script_data *screenscripts[NUMSCRIPTSCREEN];
509 script_data *dmapscripts[NUMSCRIPTSDMAP];
510 script_data *itemspritescripts[NUMSCRIPTSITEMSPRITE];
511 script_data *comboscripts[NUMSCRIPTSCOMBODATA];
512 script_data *subscreenscripts[NUMSCRIPTSSUBSCREEN];
513
514 extern string zScript;
515 char zScriptBytes[512];
516 char zLastVer[512] = { 0 };
517 SAMPLE customsfxdata[WAV_COUNT];
518 uint8_t customsfxflag[WAV_COUNT>>3];
519 int32_t sfxdat=1;
520
521 int32_t onImport_ComboAlias();
522 int32_t onExport_ComboAlias();
523
524 void set_console_state();
525
526 void clearConsole()
527 {
528 if(!console_is_open) return;
529 zscript_coloured_console.cls(CConsoleLoggerEx::COLOR_BACKGROUND_BLACK);
530 zscript_coloured_console.gotoxy(0,0);
531 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
532 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"ZQuest Classic Logging Console\n");
533 }
534
535 void initConsole()
536 {
537 if(console_is_open) return;
538 console_is_open = 1;
539 set_console_state();
540 zscript_coloured_console.Create("ZQuest Classic Logging Console", 600, 200);
541 clearConsole();
542 }
543
544 11 void killConsole()
545 {
546
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!console_is_open) return;
547 console_is_open = 0;
548 set_console_state();
549 zscript_coloured_console.kill();
550 11 }
551
552 int toggleConsole()
553 {
554 console_is_open ? killConsole() : initConsole();
555 zc_set_config("zquest","open_debug_console",console_is_open?1:0);
556 return D_O_K;
557 }
558
559 int showHotkeys()
560 {
561 hotkeys_run();
562 return D_O_K;
563 }
564
565 extern map_and_screen map_page[MAX_MAPPAGE_BTNS];
566
567 int32_t do_OpenQuest()
568 {
569 return onOpen();
570 }
571
572 int32_t do_NewQuest()
573 {
574 //clear the panel recent screen buttons to prevent crashes from invalid maps
575 for ( int32_t q = 0; q < 9; q++ )
576 {
577 map_page[q].map = 0;
578 map_page[q].screen = 0;
579 }
580 Map.setCurrMap(0);
581 Map.setCurrScr(0);
582 return onNew();
583 }
584
585 extern int CheckerCol1, CheckerCol2;
586 int32_t alignment_arrow_timer=0;
587 int32_t Flip=0,Combo=0,CSet=2,current_combolist=0,current_comboalist=0,current_cpoollist=0,current_cautolist=0,current_mappage=0;
588 int32_t Flags=0,Flag=0,menutype=(m_block);
589 int MouseScroll = 0, SavePaths = 0, CycleOn = 0, ShowGrid = 0, ShowScreenGrid = 0, ShowRegionGrid = 0, GridColor = 15, ShowCurScreenOutline = 1,
590 CmbCursorCol = 15, TilePgCursorCol = 15, CmbPgCursorCol = 15, TTipHLCol = 13,
591 TileProtection = 0, ComboProtection = 0, NoScreenPreview = 0, MMapCursorStyle = 0,
592 LayerDitherBG = -1, LayerDitherSz = 2, RulesetDialog = 0,
593 EnableTooltips = 0, TooltipsHighlight = 0, ShowFFScripts = 0, ShowSquares = 0,
594 ShowFFCs = 0, ShowInfo = 0, skipLayerWarning = 0,
595 DisableLPalShortcuts = 1, DisableCompileConsole = 0, numericalFlags = 0,
596 ActiveLayerHighlight = 0, DragCenterOfSquares = 0, SmartFFCPlacement = 0;
597 uint8_t InvalidBG = 0;
598 bool NoHighlightLayer0 = false;
599 // If true, uses "MapViewRTI" to draw editor screens. This allows for multiples palettes on the
600 // screen at once, and for higher resolution.
601 // Note: this is the default currently, and eventually the option should be removed and the
602 // "low-quality" rendering removed. Hasn't been done just yet just in case this causes regressions.
603 bool HighQualityScreenRendering = true;
604 int32_t FlashWarpSquare = -1, FlashWarpClk = 0; // flash the destination warp return when ShowSquares is active
605 uint8_t ViewLayer3BG = 0, ViewLayer2BG = 0;
606 int32_t window_width, window_height;
607 bool ShowFPS = false, SaveDragResize = false, DragAspect = false, SaveWinPos=false;
608 bool allowHideMouse = false;
609 double aspect_ratio = LARGE_H / double(LARGE_W);
610 int window_min_width = 0, window_min_height = 0;
611 int32_t ComboBrush = 0; //show the brush instead of the normal mouse
612 int32_t ComboBrushPause = 0; //temporarily disable the combo brush
613 int32_t FloatBrush = 0; //makes the combo brush float a few pixels up and left
614 int AutoBrush = 0; //Drag to size the brush on the combo panes
615 bool AutoBrushRevert = false; //Revert after placing
616 int LinkedScroll = 0;
617 //complete with shadow
618 int32_t OpenLastQuest = 0; //makes the program reopen the quest that was
619 //open at the time you quit
620 int32_t ShowMisalignments = 0; //makes the program display arrows over combos that are
621 //not aligned with the next screen.
622 int32_t AnimationOn = 0; //animate the combos in zquest?
623 int32_t AutoBackupRetention = 0; //use auto-backup feature? if so, how many backups (1-10) to keep
624 int32_t AutoSaveInterval = 0; //how often a timed autosave is made (not overwriting the current file)
625 int32_t UncompressedAutoSaves = 0; //should timed saves be uncompressed/encrypted?
626 int32_t KeyboardRepeatDelay = 0; //the time in milliseconds after holding down a key that the key starts to repeat
627 int32_t KeyboardRepeatRate = 0; //the time in milliseconds between each repetition of a repeated key
628
629 time_t auto_save_time_start, auto_save_time_current;
630 double auto_save_time_diff = 0;
631 int32_t AutoSaveRetention = 0; //how many autosaves of a quest to keep
632 int32_t ImportMapBias = 0; //tells what has precedence on map importing
633 int32_t BrushWidth=1, BrushHeight=1;
634 bool saved = true, autosaved = true;
635 bool __debug=false;
636 int32_t LayerMaskInt[7]={0};
637 int32_t CurrentLayer=0;
638 int32_t DuplicateAction[4]={0};
639 int32_t OnlyCheckNewTilesForDuplicates = 0;
640 int32_t try_recovering_missing_scripts = 0;
641
642 uint8_t PreFillTileEditorPage = 0, PreFillComboEditorPage = 0;
643 int32_t DMapEditorLastMaptileUsed = 0;
644
645 /*
646 , HorizontalDuplicateAction;
647 int32_t VerticalDuplicateAction, BothDuplicateAction;
648 */
649 word msg_count = 0;
650 int32_t LeechUpdate = 0;
651 int32_t LeechUpdateTiles = 0;
652 int32_t SnapshotFormat = 0;
653 byte SnapshotScale = 0;
654
655 byte Color = 0;
656 extern int32_t jwin_pal[jcMAX];
657 int32_t gui_colorset=99;
658
659 static int32_t combo_apos=0; //currently selected combo alias
660 int32_t alias_origin=0;
661 int32_t alias_cset_mod=0;
662
663 static int32_t combo_pool_pos=0; //currently selected combo pool
664 bool weighted_cpool = true;
665 bool cpool_prev_visible = false;
666
667 static int32_t combo_auto_pos=0; //currently selected autocombo
668 byte cauto_height = 1;
669
670 bool trip=false;
671
672 int32_t fill_type=1;
673
674 bool first_save=false;
675 char *filepath,*midipath,*datapath,*imagepath,*tmusicpath,*last_timed_save;
676 string helpstr, zstringshelpstr;
677
678 ZCMUSIC *zcmusic = NULL;
679 ZCMIXER *zcmixer = NULL;
680 int32_t midi_volume = 255;
681 extern int32_t prv_mode;
682 int32_t prv_warp = 0;
683 int32_t prv_twon = 0;
684
685 int32_t Frameskip = 0, RequestedFPS = 60, zqUseWin32Proc = 1;
686 int32_t zqColorDepth = 8;
687 int32_t joystick_index=0;
688
689 11 void set_last_timed_save(char const* buf)
690 {
691
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11 if(buf && buf[0])
692 {
693 if(buf != last_timed_save)
694 strcpy(last_timed_save, buf);
695 }
696 else
697 {
698 11 last_timed_save[0] = 0;
699 11 buf = nullptr;
700 }
701 11 zc_set_config("zquest","last_timed_save",buf);
702 11 }
703
704 17 void mark_save_dirty()
705 {
706 17 saved = false;
707 17 autosaved = false;
708 17 }
709
710 void loadlvlpal(int32_t level);
711 bool get_debug()
712 {
713 return __debug;
714 //return true;
715 }
716
717 void set_debug(bool d)
718 {
719 __debug=d;
720 return;
721 }
722
723 bool handle_quit()
724 {
725 if(onExit()==D_CLOSE)
726 return (exiting_program = true);
727 return false;
728 }
729 bool handle_close_btn_quit()
730 {
731 if(close_button_quit)
732 {
733 close_button_quit=false;
734 return handle_quit();
735 }
736 return false;
737 }
738 // **** Timers ****
739
740 volatile int32_t lastfps=0;
741 volatile int32_t framecnt=0;
742 size_t cpoolbrush_index = 0;
743
744 // quest data
745 12 zquestheader header;
746 byte midi_flags[MIDIFLAGS_SIZE];
747 byte music_flags[MUSICFLAGS_SIZE];
748 byte *quest_file;
749 int32_t msg_strings_size;
750 zctune *customtunes;
751 //emusic *enhancedMusic;
752 ZCHEATS zcheats;
753 byte use_cheats;
754 byte use_tiles;
755 // Note: may not be null-terminated (must refactor writecolordata to fix).
756 char palnames[MAXLEVELS][17];
757 char zquestdat_sig[52];
758 char qstdat_str[2048];
759
760 int32_t gme_track=0;
761
762 int32_t dlevel; // just here until gamedata is properly done
763
764 12 bool bad_version(int32_t ver)
765 {
766
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(ver < 0x170)
767 return true;
768
769 12 return false;
770 12 }
771
772 // These are for drawing eyeballs correctly in combo_tile.
773 zfix HeroModifiedX()
774 {
775 return gui_mouse_x() - 7;
776 }
777 zfix HeroModifiedY()
778 {
779 return gui_mouse_y() - 7;
780 }
781
782
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu import_250_menu
783 48 {
784
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&DMaps", onImport_DMaps },
785
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Combo Table", onImport_Combos },
786
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Combo Alias", onImport_ComboAlias },
787 };
788
789
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu import_graphics
790 180 {
791
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Palettes", onImport_Pals },
792
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
793
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Tileset (&Full)", onImport_Tiles },
794
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Tile Pack", onImport_Tilepack },
795
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "T&ile Pack to...", onImport_Tilepack_To },
796
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
797
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Combo Set (Range)", onImport_Combos },
798
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Combo Pack (Full, 1:1)", onImport_Combopack },
799
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Combo Pack to... (Dest)", onImport_Combopack_To },
800
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
801
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Combo &Alias Pack", onImport_Comboaliaspack },
802
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Combo A&lias Pack to...", onImport_Comboaliaspack_To },
803
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
804
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Doorsets", onImport_Doorset },
805 };
806
807
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu import_menu
808 120 {
809
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Enemies", onImport_Guys },
810
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Map", onImport_Map },
811
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&DMaps", onImport_DMaps },
812
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Strings (.tsv)", onImport_StringsTSV },
813
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "String Table (deprecated)", onImport_Msgs },
814
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
815
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Graphics", &import_graphics },
816
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
817
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "2.50 (Broken)", &import_250_menu },
818 };
819
820
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu export_250_menu
821 60 {
822
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&DMaps", onExport_DMaps },
823
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Combo Table", onExport_Combos },
824
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Combo Alias", onExport_ComboAlias },
825
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Graphics Pack", onExport_ZGP },
826 };
827
828
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu zq_help_menu
829 36 {
830
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Editor Help", onHelp },
831
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Strings Help", onZstringshelp },
832 };
833
834
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu export_graphics
835 144 {
836
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Palettes", onExport_Pals },
837
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
838
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Tileset (&Full)", onExport_Tiles },
839
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Tile Pack", onExport_Tilepack },
840
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
841
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Combo Set", onExport_Combos },
842
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Combo Pack", onExport_Combopack },
843
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
844
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Combo &Alias Pack", onExport_Comboaliaspack },
845
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
846
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Doorsets", onExport_Doorset },
847 };
848
849
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu export_menu
850 132 {
851 #ifdef _WIN32
852 { "&Package", onExport_Package },
853 #endif
854
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Enemies", onExport_Guys },
855
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Map", onExport_Map },
856
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&DMaps", onExport_DMaps },
857
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
858
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Strings (.tsv)", onExport_StringsTSV },
859
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "String Table (deprecated)", onExport_Msgs },
860
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
861
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Graphics", &export_graphics },
862
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
863
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "2.50 (Broken)", &export_250_menu },
864 };
865
866
867
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu recent_menu
868 132 {
869
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
870
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
871
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
872
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
873
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
874
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
875
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
876
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
877
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
878
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
879 };
880 static char rec_menu_fullpaths[10][512];
881 static char rec_menu_strs[10][64];
882
883 int32_t customOpen(char const* path);
884 void do_recent_quest(uint32_t ind)
885 {
886 if(ind > 9) return;
887 strcpy(temppath, rec_menu_fullpaths[ind]);
888 customOpen(temppath);
889 }
890 int32_t do_RecentQuest_0() { do_recent_quest(0); return D_O_K; }
891 int32_t do_RecentQuest_1() { do_recent_quest(1); return D_O_K; }
892 int32_t do_RecentQuest_2() { do_recent_quest(2); return D_O_K; }
893 int32_t do_RecentQuest_3() { do_recent_quest(3); return D_O_K; }
894 int32_t do_RecentQuest_4() { do_recent_quest(4); return D_O_K; }
895 int32_t do_RecentQuest_5() { do_recent_quest(5); return D_O_K; }
896 int32_t do_RecentQuest_6() { do_recent_quest(6); return D_O_K; }
897 int32_t do_RecentQuest_7() { do_recent_quest(7); return D_O_K; }
898 int32_t do_RecentQuest_8() { do_recent_quest(8); return D_O_K; }
899 int32_t do_RecentQuest_9() { do_recent_quest(9); return D_O_K; }
900
901 2 void refresh_recent_menu()
902 {
903 2 int32_t (*procs[10])(void) = {
904 do_RecentQuest_0, do_RecentQuest_1, do_RecentQuest_2, do_RecentQuest_3,
905 do_RecentQuest_4, do_RecentQuest_5, do_RecentQuest_6,
906 do_RecentQuest_7, do_RecentQuest_8, do_RecentQuest_9
907 };
908
5/8
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
2 static MenuItem nilitem("---",nullptr,nullopt,true);
909
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 20 times.
22 for(auto q = 0; q < 10; ++q)
910 {
911 20 MenuItem& mit = *recent_menu.at(q);
912 20 bool valid = rec_menu_fullpaths[q][0] != '-';
913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(valid)
914 mit = MenuItem(rec_menu_strs[q],procs[q]);
915 20 else mit = nilitem;
916 20 }
917 2 }
918
919 1 void load_recent_quests()
920 {
921 1 char configname[64] = "rec_qst_";
922 1 char* ptr = &configname[strlen(configname)];
923 1 char buf[512] = {0};
924
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1 times.
11 for(auto q = 0; q < 10; ++q)
925 {
926 10 sprintf(ptr, "%d", q); //increment the configname value
927 10 char const* qst_str = zc_get_config("recent",configname,nullptr);
928
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(qst_str[0])
929 {
930 strncpy(rec_menu_fullpaths[q], qst_str, 511);
931 relativize_path(buf, rec_menu_fullpaths[q]);
932 if(strlen(buf) > 62)
933 {
934 buf[60] = buf[61] = buf[62] = '.'; //add "..." as the last 3 characters
935 }
936 strncpy(rec_menu_strs[q], buf, 63);
937 }
938 else
939 {
940 10 strcpy(rec_menu_fullpaths[q], "---");
941 10 strcpy(rec_menu_strs[q], "---");
942 }
943 10 rec_menu_fullpaths[q][511] = 0;
944 10 rec_menu_strs[q][63] = 0;
945 10 }
946 1 refresh_recent_menu();
947 1 }
948
949 void write_recent_quests()
950 {
951 char configname[64] = "rec_qst_";
952 char* ptr = &configname[strlen(configname)];
953 for(auto q = 0; q < 10; ++q)
954 {
955 sprintf(ptr, "%d", q); //increment the configname value
956 zc_set_config("recent",configname,(rec_menu_fullpaths[q][0]!='-') ? rec_menu_fullpaths[q] : nullptr);
957 }
958 }
959
960 void update_recent_quest(char const* path)
961 {
962 int32_t ind = -1;
963 for(auto q = 0; q < 10; ++q)
964 {
965 if(!strcmp(path, rec_menu_fullpaths[q]))
966 {
967 ind = q;
968 break;
969 }
970 }
971 if(ind > -1)
972 {
973 for(auto q = ind; q > 0; --q)
974 {
975 strcpy(rec_menu_fullpaths[q], rec_menu_fullpaths[q-1]);
976 strcpy(rec_menu_strs[q], rec_menu_strs[q-1]);
977 }
978 }
979 else
980 {
981 int32_t free_ind = 9; //if none found, override the last index
982 for(auto q = 0; q < 9; ++q)
983 {
984 if(rec_menu_fullpaths[q][0] == '-')
985 {
986 free_ind = q;
987 break;
988 }
989 }
990
991 for(auto q = free_ind; q > 0; --q)
992 {
993 strcpy(rec_menu_fullpaths[q], rec_menu_fullpaths[q-1]);
994 strcpy(rec_menu_strs[q], rec_menu_strs[q-1]);
995 }
996 }
997 char buf[512] = {0};
998 strcpy(rec_menu_fullpaths[0], path);
999 relativize_path(buf, rec_menu_fullpaths[0]);
1000 if(strlen(buf) > 62)
1001 {
1002 buf[60] = buf[61] = buf[62] = '.'; //add "..." as the last 3 characters
1003 }
1004 strncpy(rec_menu_strs[0], buf, 63);
1005 refresh_recent_menu();
1006 zc_set_config("zquest",last_quest_name,path);
1007 write_recent_quests();
1008 }
1009
1010 void reload_zq_gui()
1011 {
1012 init_custom_fonts();
1013 load_size_poses();
1014 refresh_visible_screens();
1015 update_combobrush();
1016 refresh(rCLEAR|rALL);
1017 }
1018 void change_mapscr_zoom(int delta)
1019 {
1020 int num_screens = Map.getViewSize();
1021 num_screens = std::clamp(num_screens + delta, 1, mapscreen_num_screens_to_draw_max);
1022 Map.setViewSize(num_screens);
1023 std::string qst_cfg_header = qst_cfg_header_from_path(filepath);
1024 zc_set_config(qst_cfg_header.c_str(), "zoom_num_screens", Map.getViewSize());
1025 reload_zq_gui();
1026 }
1027 void toggle_is_compact()
1028 {
1029 is_compact = !is_compact;
1030 zc_set_config("ZQ_GUI","compact_mode",is_compact?1:0);
1031 reload_zq_gui();
1032 }
1033 void toggle_merged_mode()
1034 {
1035 if(is_compact)
1036 {
1037 compact_merged_combopane = !compact_merged_combopane;
1038 zc_set_config("ZQ_GUI","merge_cpane_compact",compact_merged_combopane?1:0);
1039 }
1040 else
1041 {
1042 large_merged_combopane = !large_merged_combopane;
1043 zc_set_config("ZQ_GUI","merge_cpane_large",large_merged_combopane?1:0);
1044 }
1045 reload_zq_gui();
1046 }
1047 void toggle_compact_sqr_mode()
1048 {
1049 compact_square_panels = !compact_square_panels;
1050 zc_set_config("ZQ_GUI","square_panels_compact",compact_square_panels?1:0);
1051 reload_zq_gui();
1052 }
1053 void cycle_compact_sqr(bool down)
1054 {
1055 if(!(is_compact && compact_square_panels))
1056 return;
1057 static const int num_panels = 3;
1058 if(down)
1059 compact_active_panel = (compact_active_panel+1)%num_panels;
1060 else
1061 compact_active_panel = (compact_active_panel-1+num_panels)%num_panels;
1062 reload_zq_gui();
1063 }
1064 void toggle_favzoom_mode()
1065 {
1066 if(is_compact)
1067 {
1068 compact_zoomed_fav = !compact_zoomed_fav;
1069 zc_set_config("ZQ_GUI","zoom_fav_compact",compact_zoomed_fav?1:0);
1070 }
1071 else
1072 {
1073 large_zoomed_fav = !large_zoomed_fav;
1074 zc_set_config("ZQ_GUI","zoom_fav_large",large_zoomed_fav?1:0);
1075 }
1076 reload_zq_gui();
1077 }
1078 void toggle_cmdzoom_mode()
1079 {
1080 if(is_compact)
1081 {
1082 compact_zoomed_cmd = !compact_zoomed_cmd;
1083 zc_set_config("ZQ_GUI","zoom_cmd_compact",compact_zoomed_cmd?1:0);
1084 }
1085 else
1086 {
1087 large_zoomed_cmd = !large_zoomed_cmd;
1088 zc_set_config("ZQ_GUI","zoom_cmd_large",large_zoomed_cmd?1:0);
1089 }
1090 reload_zq_gui();
1091 }
1092
1093 enum
1094 {
1095 MENUID_FILE_SAVE,
1096 MENUID_FILE_SAVEAS,
1097 MENUID_FILE_REVERT,
1098 };
1099
1100
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu file_menu
1101 156 {
1102
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&New", do_NewQuest },
1103
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Open", do_OpenQuest },
1104
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Recent", &recent_menu },
1105
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1106
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Save", onSave, MENUID_FILE_SAVE },
1107
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Save &as...", onSaveAs, MENUID_FILE_SAVEAS },
1108
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Revert", onRevert, MENUID_FILE_REVERT },
1109
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1110
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Import", &import_menu },
1111
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Export", &export_menu },
1112 #ifndef __EMSCRIPTEN__
1113
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1114
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "E&xit", handle_quit },
1115 #endif
1116 };
1117
1118 enum
1119 {
1120 MENUID_MAPS_NEXT,
1121 MENUID_MAPS_PREV,
1122 };
1123
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu maps_menu
1124 72 {
1125
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Goto Map...", onGotoMap },
1126
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Next Map", onIncMap, MENUID_MAPS_NEXT },
1127
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Previous Map", onDecMap, MENUID_MAPS_PREV },
1128
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1129
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "D&elete Map", onDeleteMap },
1130 };
1131
1132
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu misc_menu
1133 132 {
1134
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "S&ubscreens", onEditSubscreens },
1135
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Shop Types", onShopTypes },
1136
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Bottle Types", onBottleTypes },
1137
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Bottle S&hop Types", onBottleShopTypes },
1138
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Info Types", onInfoTypes },
1139
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Warp Rings", onWarpRings },
1140
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Triforce Pieces", onTriPieces },
1141
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&End String", onEndString },
1142
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Item &Drop Sets", onItemDropSets },
1143
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Save Menus", onSaveMenus },
1144 };
1145
1146
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu spr_menu
1147 48 {
1148
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Sprite Data", onCustomWpns },
1149
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Hero", onCustomHero },
1150
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Misc Sprites", onMiscSprites },
1151 };
1152
1153
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 NewMenu colors_menu
1154 48 {
1155
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Main ", onColors_Main },
1156
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Levels ", onColors_Levels },
1157
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Sprites ", onColors_Sprites },
1158 };
1159
1160
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu defs_menu
1161 108 {
1162
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Palettes", onDefault_Pals },
1163
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Tiles", onDefault_Tiles },
1164
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Combos", onDefault_Combos },
1165
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Items", onDefault_Items },
1166
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Enemies", onDefault_Guys },
1167
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Sprite Data", onDefault_Weapons },
1168
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Map Styles", onDefault_MapStyles },
1169
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "SF&X Data", onDefault_SFX },
1170 };
1171
1172 int32_t onEditComboAlias();
1173 int32_t onEditComboPool();
1174 int32_t onEditAutoCombo();
1175
1176
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu graphics_menu
1177 144 {
1178
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Palettes ", &colors_menu },
1179
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Sprites ", &spr_menu },
1180
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Combos", onCombos },
1181
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Tiles", onTiles },
1182
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Game icons", onIcons },
1183
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Misc co&lors", onMiscColors },
1184
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Map styles", onMapStyles },
1185
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Door Combo Sets", onDoorCombos },
1186
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Combo &Aliases", [](){call_alias_pages(); return D_O_K;} },
1187
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Combo Pools", [](){call_cpool_pages(); return D_O_K;} },
1188
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Auto Combos", [](){call_autoc_pages(); return D_O_K;} },
1189 };
1190
1191
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu audio_menu
1192 48 {
1193
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "SF&X Data", onSelectSFX },
1194
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&MIDIs", onMidis },
1195
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Mis&c SFX", onMiscSFX },
1196 };
1197
1198 void set_rules(byte* newrules);
1199
1200 void call_testqst_dialog();
1201 int32_t onTestQst()
1202 {
1203 call_testqst_dialog();
1204 return D_O_K;
1205 }
1206
1207 int32_t onRulesDlg()
1208 {
1209 call_qr_dialog(21, set_rules);
1210 return D_O_K;
1211 }
1212
1213 int32_t onRulesSearch()
1214 {
1215 call_qrsearch_dialog(set_rules);
1216 return D_O_K;
1217 }
1218
1219 int32_t onZScriptSettings()
1220 {
1221 ScriptRulesDialog(quest_rules, 17, [](byte* newrules)
1222 {
1223 mark_save_dirty();
1224 memcpy(quest_rules, newrules, QR_SZ);
1225 unpack_qrs();
1226 }).show();
1227 return D_O_K;
1228 }
1229
1230 void call_zinf_dlg();
1231 int32_t onZInfo()
1232 {
1233 call_zinf_dlg();
1234 return D_O_K;
1235 }
1236
1237
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu quest_menu
1238 204 {
1239
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Options ", onRulesDlg },
1240
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Test", onTestQst },
1241
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Items", onCustomItems },
1242
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Enemies", onCustomEnemies },
1243
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Hero", onCustomHero },
1244
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Strings", onStrings },
1245
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&DMaps", onDmaps },
1246
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Map Settings", onMaps },
1247
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "I&nit Data", onInit },
1248
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Misc D&ata ", &misc_menu },
1249
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&ZInfo", onZInfo },
1250
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1251
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Graphics ", &graphics_menu },
1252
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "A&udio ", &audio_menu },
1253
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1254
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "De&faults ", &defs_menu },
1255 };
1256
1257
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu paste_menu
1258 36 {
1259
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Paste &To All", onPasteToAll },
1260
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Paste &All To All", onPasteAllToAll },
1261 };
1262
1263
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu paste_item_menu
1264 156 {
1265
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Undercombo", onPasteUnderCombo },
1266
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Secret Combos", onPasteSecretCombos },
1267
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Freeform Combos", onPasteFFCombos },
1268
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Screen &Data", onPasteScreenData },
1269
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Warps", onPasteWarps },
1270
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Warp &Return", onPasteWarpLocations },
1271
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Enemies", onPasteEnemies },
1272
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Room &Type Data", onPasteRoom },
1273
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Guy/String", onPasteGuy },
1274
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Doo&rs", onPasteDoors },
1275
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Layers", onPasteLayers },
1276
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Palette", onPastePalette },
1277 };
1278
1279 enum
1280 {
1281 MENUID_EDIT_UNDO,
1282 MENUID_EDIT_REDO,
1283 MENUID_EDIT_COPY,
1284 MENUID_EDIT_PASTE,
1285 MENUID_EDIT_PASTEALL,
1286 MENUID_EDIT_ADVPASTE,
1287 MENUID_EDIT_SPECPASTE,
1288 MENUID_EDIT_DELETE,
1289 };
1290
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu edit_menu
1291 132 {
1292
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Undo", onUndo, MENUID_EDIT_UNDO },
1293
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Redo", onRedo, MENUID_EDIT_REDO },
1294
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Copy", onCopy, MENUID_EDIT_COPY },
1295
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Paste", onPaste, MENUID_EDIT_PASTE },
1296
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Paste A&ll", onPasteAll, MENUID_EDIT_PASTEALL },
1297
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Adv. Paste ", &paste_menu, MENUID_EDIT_ADVPASTE },
1298
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Paste &Spec. ", &paste_item_menu, MENUID_EDIT_SPECPASTE },
1299
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Delete", onDelete, MENUID_EDIT_DELETE },
1300
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1301
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Maps ", &maps_menu },
1302 };
1303
1304
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu drawing_mode_menu
1305 60 {
1306
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Normal", onDrawingModeNormal, dm_normal },
1307
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Combo Alias", onDrawingModeAlias, dm_alias },
1308
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Pool", onDrawingModePool, dm_cpool },
1309
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Auto Combo", onDrawingModeAuto, dm_auto },
1310 };
1311
1312
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu integrity_check_menu
1313 48 {
1314
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&All ", onIntegrityCheckAll },
1315
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Screens ", onIntegrityCheckRooms },
1316
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Warps ", onIntegrityCheckWarps },
1317 };
1318
1319
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu quest_reports_menu
1320 108 {
1321
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Bugged Next-> Combo Locations", onBuggedNextComboLocationReport },
1322
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Combo Locations", onComboLocationReport },
1323
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Combo Type Locations", onComboTypeLocationReport },
1324
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Enemy Locations", onEnemyLocationReport },
1325
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Item Locations", onItemLocationReport },
1326
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Script Locations", onScriptLocationReport },
1327
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&What Links Here", onWhatWarpsReport },
1328
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "In&tegrity Check ", &integrity_check_menu },
1329 };
1330
1331 int32_t onPalFix();
1332 int32_t onPitFix();
1333 int32_t onStrFix()
1334 {
1335 if(get_qr(qr_OLD_STRING_EDITOR_MARGINS))
1336 {
1337 AlertDialog("Fix: Old Margins",
1338 "Fixing margins may cause strings that used to spill outside the textbox"
1339 " to instead be cut off. Are you sure?",
1340 [&](bool ret,bool)
1341 {
1342 if(ret)
1343 {
1344 set_qr(qr_OLD_STRING_EDITOR_MARGINS, 0);
1345 mark_save_dirty();
1346 }
1347 }).show();
1348 }
1349 if(get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT))
1350 {
1351 AlertDialog("Fix: Old Frame Size",
1352 "This will fix the frame size of all strings. No visual changes should occur,"
1353 " as the string width/height will be fixed, but the compat QR will also be unchecked.",
1354 [&](bool ret,bool)
1355 {
1356 if(ret)
1357 {
1358 for(auto q = 0; q < msg_count; ++q)
1359 {
1360 MsgStrings[q].w += 16;
1361 MsgStrings[q].h += 16;
1362 }
1363 set_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT, 0);
1364 mark_save_dirty();
1365 }
1366 }).show();
1367 }
1368 return D_O_K;
1369 }
1370
1371 int32_t onRemoveOldArrivalSquare();
1372 enum
1373 {
1374 MENUID_FIXTOOL_OLDSTRING,
1375 };
1376
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu fixtools_menu
1377 96 {
1378
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Color Set Fix", onCSetFix },
1379
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Liquid Solidity Fix", onWaterSolidity },
1380
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Effect Square Fix", onEffectFix },
1381
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Level Palette Fix", onPalFix },
1382
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Pit and Liquid Damage Fix", onPitFix },
1383
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Old Strings Fix", onStrFix, MENUID_FIXTOOL_OLDSTRING },
1384
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Green Arrival Square Fix", onRemoveOldArrivalSquare },
1385 };
1386
1387
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu tool_menu
1388 132 {
1389
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Combo &Flags", onFlags, nullopt, MFL_EXIT_PRE_PROC },
1390
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Fix &Tools ", &fixtools_menu },
1391
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&NES Dungeon Template", onTemplate },
1392
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Apply Template to All", onReTemplate },
1393
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1394
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Preview Mode", onPreviewMode },
1395
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Drawing &Mode ", &drawing_mode_menu },
1396
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1397
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&List Combos Used", onUsedCombos },
1398
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Quest Reports ", &quest_reports_menu },
1399 };
1400
1401 int32_t onLayer3BG()
1402 {
1403 ViewLayer3BG = ViewLayer3BG ? 0 : 1;
1404 zc_set_config("zquest","layer3_bg",ViewLayer3BG);
1405 return D_O_K;
1406 }
1407 int32_t onLayer2BG()
1408 {
1409 ViewLayer2BG = ViewLayer2BG ? 0 : 1;
1410 zc_set_config("zquest","layer2_bg",ViewLayer2BG);
1411 return D_O_K;
1412 }
1413 int onGridToggle();
1414 int onToggleHighQualityScreenRendering();
1415 enum
1416 {
1417 MENUID_VIEW_WALKABILITY,
1418 MENUID_VIEW_FLAGS,
1419 MENUID_VIEW_CSET,
1420 MENUID_VIEW_TYPES,
1421 MENUID_VIEW_INFO,
1422 MENUID_VIEW_SQUARES,
1423 MENUID_VIEW_FFCS,
1424 MENUID_VIEW_SCRIPTNAMES,
1425 MENUID_VIEW_GRID,
1426 MENUID_VIEW_SCREENGRID,
1427 MENUID_VIEW_REGIONGRID,
1428 MENUID_VIEW_CURSCROUTLINE,
1429 MENUID_VIEW_DARKNESS,
1430 MENUID_VIEW_L2BG,
1431 MENUID_VIEW_L3BG,
1432 MENUID_VIEW_LAYERHIGHLIGHT,
1433 MENUID_VIEW_HIGH_QUALITY_SCREEN_RENDERING,
1434 };
1435
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 NewMenu view_menu
1436 264 {
1437
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "View &Map...", onViewMap },
1438
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "View &Palette", onShowPal },
1439
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1440
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Show &Walkability", onShowWalkability, MENUID_VIEW_WALKABILITY },
1441
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Show &Flags", onShowFlags, MENUID_VIEW_FLAGS },
1442
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Show &CSets", onShowCSet, MENUID_VIEW_CSET },
1443
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Show &Types", onShowCType, MENUID_VIEW_TYPES },
1444
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1445
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Show Screen &Info", onToggleShowInfo, MENUID_VIEW_INFO },
1446
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Show &Squares", onToggleShowSquares, MENUID_VIEW_SQUARES },
1447
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Show FFCs", onToggleShowFFCs, MENUID_VIEW_FFCS },
1448
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Show Script &Names", onToggleShowScripts, MENUID_VIEW_SCRIPTNAMES },
1449
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Show &Grid", onGridToggle, MENUID_VIEW_GRID },
1450
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Show Screen G&rid", onToggleScreenGrid, MENUID_VIEW_SCREENGRID },
1451
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Show Region Grid", onToggleRegionGrid, MENUID_VIEW_REGIONGRID },
1452
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Show Current Screen Outline", onToggleCurrentScreenOutline, MENUID_VIEW_CURSCROUTLINE },
1453
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Show &Darkness", onShowDarkness, MENUID_VIEW_DARKNESS },
1454
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Layer 2 is Background", onLayer2BG, MENUID_VIEW_L2BG },
1455
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Layer 3 is Background", onLayer3BG, MENUID_VIEW_L3BG },
1456
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Highlight Current Layer", onToggleHighlightLayer, MENUID_VIEW_LAYERHIGHLIGHT },
1457
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "High &Quality Screen Rendering", onToggleHighQualityScreenRendering, MENUID_VIEW_HIGH_QUALITY_SCREEN_RENDERING },
1458 };
1459
1460 11 void set_rules(byte* newrules)
1461 {
1462 11 mark_save_dirty();
1463
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(newrules != quest_rules)
1464 memcpy(quest_rules, newrules, QR_SZ);
1465 11 unpack_qrs();
1466
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2 times.
11 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
1467 {
1468 2 combobuf[0].walk = 0xF0;
1469 2 combobuf[0].type = 0;
1470 2 combobuf[0].flag = 0;
1471 2 }
1472
1473 // For 2.50.0 and 2.50.1
1474
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2 times.
11 if(get_qr(qr_VERYFASTSCROLLING))
1475 2 set_qr(qr_FASTDNGN, 1);
1476 11 }
1477
1478 int32_t onSelectFFCombo();
1479
1480 void onScreenNotes()
1481 {
1482 edit_screen_notes(Map.CurrScr(), Map.getCurrMap(), Map.getCurrScr());
1483 }
1484
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu data_menu
1485 216 {
1486
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Screen Data", onScrData },
1487
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Freeform Combos", onSelectFFCombo },
1488
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "La&yers", onLayers },
1489
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Tile Warp", onTileWarp },
1490
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Side &Warp", onSideWarp },
1491
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Secret &Combos", onSecretCombo },
1492
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Under Combo", onUnderCombo },
1493
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Doors", onDoors },
1494
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Maze Path", onPath },
1495
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1496
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Item", onItem },
1497
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Enemies", onEnemies },
1498
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Palette", onScreenPalette },
1499
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1500
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Room Data", onRoom },
1501
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Notes", onScreenNotes },
1502
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Browse Notes", browse_screen_notes },
1503 };
1504
1505
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu tunes_menu
1506 252 {
1507
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "ZC Forever", playZCForever },
1508
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Wind Fish", playTune1 },
1509
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Overworld", playTune2 },
1510
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Hyrule Castle", playTune3 },
1511
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Lost Woods", playTune4 },
1512
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Great Sea", playTune5 },
1513
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "East Hyrule", playTune6 },
1514
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Dancing Dragon", playTune7 },
1515
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Stone Tower", playTune8 },
1516
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Villages", playTune9 },
1517
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Swamp + Desert", playTune10 },
1518
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Outset Island", playTune11 },
1519
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Kakariko Village", playTune12 },
1520
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Clock Town", playTune13 },
1521
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Temple", playTune14 },
1522
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Dark World", playTune15 },
1523
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Dragon Roost", playTune16 },
1524
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Horse Race", playTune17 },
1525
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Credits", playTune18 },
1526
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Zelda's Lullaby", playTune19 },
1527 };
1528
1529 enum
1530 {
1531 MENUID_MEDIA_TUNES,
1532 MENUID_MEDIA_PLAYMUSIC,
1533 MENUID_MEDIA_CHANGETRACK,
1534 };
1535
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu media_menu
1536 60 {
1537
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Ambient Music ", &tunes_menu, MENUID_MEDIA_TUNES },
1538
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Play music", playMusic, MENUID_MEDIA_PLAYMUSIC },
1539
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Change track", changeTrack, MENUID_MEDIA_CHANGETRACK },
1540
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Stop tunes", stopMusic },
1541 };
1542
1543 enum
1544 {
1545 MENUID_ETC_VIDMODE,
1546 MENUID_ETC_FULLSCREEN,
1547 MENUID_ETC_DEBUG_CONSOLE,
1548 };
1549
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu etc_menu
1550 192 {
1551
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Help", &zq_help_menu },
1552
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&About", onAbout },
1553
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Video Mode", onZQVidMode, MENUID_ETC_VIDMODE },
1554
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Options...", onOptions },
1555
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Hotkeys...", do_zq_hotkey_dialog },
1556
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&List Hotkeys...", do_zq_list_hotkeys_dialog },
1557
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Fullscreen", onFullScreen, MENUID_ETC_FULLSCREEN },
1558
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1559
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&View Pic...", onViewPic },
1560
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Media", &media_menu },
1561
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1562
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Debug Console", toggleConsole, MENUID_ETC_DEBUG_CONSOLE },
1563
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Clear Quest Filepath", onClearQuestFilepath },
1564
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Take ZQ Snapshot", onMenuSnapshot },
1565
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Take &Screen Snapshot", onMapscrSnapshot },
1566 };
1567
1568
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu zscript_menu
1569 60 {
1570
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Compile &ZScript...", onCompileScript },
1571
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1572
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Compiler Settings", onZScriptCompilerSettings },
1573
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Quest Script Settings", onZScriptSettings },
1574 };
1575
1576 void set_console_state()
1577 {
1578 etc_menu.select_uid(MENUID_ETC_DEBUG_CONSOLE, console_is_open);
1579 }
1580
1581
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 TopMenu the_menu
1582 108 {
1583
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&File", &file_menu },
1584
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Quest", &quest_menu },
1585
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Edit", &edit_menu },
1586
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&View", &view_menu },
1587
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Tools", &tool_menu },
1588
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Screen", &data_menu },
1589
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&ZScript", &zscript_menu },
1590
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Et&C", &etc_menu },
1591 };
1592
1593 void rebuild_trans_table();
1594 int32_t launchPicViewer(BITMAP **pictoview, PALETTE pal,
1595 int32_t &px2, int32_t &py2, double &scale, bool isviewingmap, bool skipmenu = false);
1596
1597 int32_t onResetTransparency()
1598 {
1599 restore_mouse();
1600 rebuild_trans_table();
1601 jwin_alert("Notice","Translucency Table Rebuilt",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
1602
1603 refresh(rALL);
1604 return D_O_K;
1605 }
1606
1607 int32_t onFullScreen()
1608 {
1609 get_palette(RAMpal);
1610 bool windowed=is_windowed_mode()!=0;
1611 all_toggle_fullscreen(windowed);
1612
1613 gui_mouse_focus=0;
1614 gui_bg_color=jwin_pal[jcBOX];
1615 gui_fg_color=jwin_pal[jcBOXFG];
1616 MouseSprite::set(ZQM_NORMAL);
1617 zc_set_palette(RAMpal);
1618 position_mouse(zq_screen_w/2,zq_screen_h/2);
1619 set_display_switch_mode(SWITCH_BACKGROUND);
1620 set_display_switch_callback(SWITCH_OUT, switch_out);
1621 set_display_switch_callback(SWITCH_IN, switch_in);
1622 zc_set_config("zquest","fullscreen", is_windowed_mode() ? 0 : 1);
1623 return D_REDRAW;
1624 }
1625
1626 int32_t onEnter()
1627 {
1628 if(key[KEY_ALT]||key[KEY_ALTGR])
1629 {
1630 return onFullScreen();
1631 }
1632
1633 return D_O_K;
1634 }
1635
1636 //PROC, x, y, w, h, fg, bg, key, flags, d1, d2, *dp, *dp2, *dp3
1637
1638 //*text, (*proc), *child, flags, *dp
1639
1640 void run_zq_frame();
1641 int32_t d_nbmenu_proc(int32_t msg,DIALOG *d,int32_t c);
1642
1643
1644 /*int32_t onY()
1645 {
1646 return D_O_K;
1647 }*/
1648
1649 int32_t onToggleGrid(bool color)
1650 {
1651 if(color)
1652 {
1653 GridColor=(GridColor+8)%16;
1654 zc_set_config("zquest", "grid_color", GridColor);
1655 }
1656 else
1657 {
1658 ShowGrid=!ShowGrid;
1659 zc_set_config("zquest","show_grid",ShowGrid);
1660 }
1661
1662 return D_O_K;
1663 }
1664
1665 int onGridToggle()
1666 {
1667 return onToggleGrid(CHECK_CTRL_CMD);
1668 }
1669
1670 int onToggleHighQualityScreenRendering()
1671 {
1672 HighQualityScreenRendering = !HighQualityScreenRendering;
1673 zc_set_config("zquest","high_quality_screen_rendering",HighQualityScreenRendering);
1674
1675 if (!HighQualityScreenRendering)
1676 {
1677 mapview_get_rti()->remove();
1678 }
1679
1680 return D_O_K;
1681 }
1682
1683 int32_t onToggleScreenGrid()
1684 {
1685 ShowScreenGrid=!ShowScreenGrid;
1686 zc_set_config("zquest","show_screen_grid",ShowScreenGrid);
1687 return D_O_K;
1688 }
1689
1690 int32_t onToggleRegionGrid()
1691 {
1692 ShowRegionGrid=!ShowRegionGrid;
1693 zc_set_config("zquest","show_region_grid",ShowRegionGrid);
1694 return D_O_K;
1695 }
1696
1697 int32_t onToggleCurrentScreenOutline()
1698 {
1699 ShowCurScreenOutline=!ShowCurScreenOutline;
1700 zc_set_config("zquest","show_current_screen_outline",ShowCurScreenOutline);
1701 return D_O_K;
1702 }
1703
1704 int32_t onToggleShowScripts()
1705 {
1706 ShowFFScripts=!ShowFFScripts;
1707 zc_set_config("zquest","showffscripts",ShowFFScripts);
1708 return D_O_K;
1709 }
1710
1711 int32_t onToggleShowFFCs()
1712 {
1713 ShowFFCs=!ShowFFCs;
1714 zc_set_config("zquest","showffcs",ShowFFCs);
1715 return D_O_K;
1716 }
1717
1718 int32_t onToggleShowSquares()
1719 {
1720 ShowSquares=!ShowSquares;
1721 zc_set_config("zquest","showsquares",ShowSquares);
1722 return D_O_K;
1723 }
1724
1725 int32_t onToggleShowInfo()
1726 {
1727 ShowInfo=!ShowInfo;
1728 zc_set_config("zquest","showinfo",ShowInfo);
1729 return D_O_K;
1730 }
1731
1732 int32_t onToggleHighlightLayer()
1733 {
1734 ActiveLayerHighlight = ActiveLayerHighlight ? 0 : 1;
1735 zc_set_config("zquest","hl_active_lyr",ActiveLayerHighlight);
1736 return D_O_K;
1737 }
1738
1739 int onKeySlash()
1740 {
1741 if(key[KEY_LSHIFT] || key[KEY_RSHIFT])
1742 {
1743 onAbout();
1744 }
1745 return D_O_K;
1746 }
1747
1748 int onAKey()
1749 {
1750 if(prv_mode)
1751 Map.set_prvadvance(1);
1752 return D_O_K;
1753 }
1754
1755 int onReloadPreview()
1756 {
1757 if(prv_mode)
1758 {
1759 Map.set_prvscr(Map.get_prv_map(), Map.get_prv_scr());
1760 Map.set_prvcmb(0);
1761 }
1762 return D_O_K;
1763 }
1764 int onSecretsPreview()
1765 {
1766 if(prv_mode)
1767 {
1768 Map.prv_secrets(false);
1769 refresh(rALL);
1770 }
1771 return D_O_K;
1772 }
1773
1774 int onSKey()
1775 {
1776 if(CHECK_CTRL_CMD)
1777 {
1778 if(key[KEY_LSHIFT] || key[KEY_RSHIFT])
1779 {
1780 onSaveAs();
1781 }
1782 else
1783 {
1784 if(!saved)
1785 onSave();
1786 }
1787 }
1788 else if(prv_mode)
1789 {
1790 Map.prv_secrets(false);
1791 refresh(rALL);
1792 }
1793 else onStrings();
1794 return D_O_K;
1795 }
1796 int onSetNewLayer(int newlayer)
1797 {
1798 CurrentLayer = newlayer;
1799 refresh(rALL);
1800 return D_O_K;
1801 }
1802 void lpal_dsa()
1803 {
1804 info_dsa("Level Palette Shortcuts",
1805 "You currently have level palette shortcuts disabled."
1806 " These can be re-enabled in 'Etc->Options', on the toggle 'Disable Level Palette Shortcuts'.",
1807 "dsa_lpal");
1808 }
1809 int onScreenLPal(int lpal)
1810 {
1811 if(DisableLPalShortcuts)
1812 {
1813 lpal_dsa();
1814 return D_O_K;
1815 }
1816 mark_save_dirty();
1817 Map.setcolor(lpal);
1818 refresh(rSCRMAP);
1819 return D_O_K;
1820 }
1821
1822 int32_t onPressEsc()
1823 {
1824 if(zoomed_minimap)
1825 mmap_set_zoom(false);
1826 else return onExit();
1827 return D_O_K;
1828 }
1829
1830 static DIALOG dialogs[] =
1831 {
1832 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
1833 { d_nbmenu_proc, 0, 0, 0, 13, 0, 0, 0, D_USER, 0, 0, (void *) &the_menu, NULL, NULL },
1834 { d_zq_hotkey_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
1835
1836 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onHelp, NULL, NULL },
1837 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_ESC, 0, (void *) onPressEsc, NULL, NULL },
1838 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 39, 0, 0, 0, (void *) onUsedCombos, NULL, NULL },
1839 { d_vsync_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
1840 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
1841 };
1842
1843
1844 int32_t onDecColour()
1845 {
1846 if ( CHECK_CTRL_CMD )
1847 {
1848 return onDecScrPal16();
1849 }
1850
1851 else if ( key[KEY_LSHIFT] || key[KEY_RSHIFT] )
1852 {
1853 return onDecScrPal();
1854 }
1855
1856 else
1857 {
1858 return onDecreaseCSet();
1859 }
1860 }
1861
1862 int32_t onIncColour()
1863 {
1864
1865 if ( CHECK_CTRL_CMD )
1866 {
1867 return onIncScrPal16();
1868 }
1869
1870 else if ( key[KEY_LSHIFT] || key[KEY_RSHIFT] )
1871 {
1872 return onIncScrPal();
1873 }
1874
1875 else
1876 {
1877 return onIncreaseCSet();
1878 }
1879 }
1880
1881 static DIALOG getnum_dlg[] =
1882 {
1883 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
1884 12 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
1885 12 { jwin_rtext_proc, 114, 104+4, 48, 8, jwin_pal[jcBOXFG], jwin_pal[jcBOX], 0, 0, 0, 0, (void *) "Value:", NULL, NULL },
1886 12 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
1887 12 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
1888 12 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
1889 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
1890 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
1891 };
1892
1893 int32_t getnumber(const char *prompt,int32_t initialval)
1894 {
1895 cancelgetnum=true;
1896 char buf[20];
1897 sprintf(buf,"%d",initialval);
1898 getnum_dlg[0].dp=(void *)prompt;
1899 getnum_dlg[0].dp2=get_zc_font(font_lfont);
1900 getnum_dlg[2].dp=(void *)buf;
1901
1902 large_dialog(getnum_dlg);
1903
1904 int32_t ret=do_zqdialog(getnum_dlg,2);
1905
1906 if(ret!=0&&ret!=4)
1907 {
1908 cancelgetnum=false;
1909 }
1910
1911 if(ret==3)
1912 return atoi(buf);
1913
1914 return initialval;
1915 }
1916
1917 static DIALOG save_tiles_dlg[] =
1918 {
1919 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
1920
1921
1922 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Save Tile Pack", NULL, NULL },
1923 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
1924 //for future tabs
1925 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
1926 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
1927 //4
1928 { jwin_text_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "First", NULL, NULL },
1929 { jwin_edit_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
1930 //6
1931 { jwin_text_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
1932 { jwin_edit_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
1933 //8
1934 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Save", NULL, NULL },
1935 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
1936 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
1937 };
1938
1939
1940 void savesometiles(const char *prompt,int32_t initialval)
1941 {
1942
1943 char firsttile[8], tilecount[8];
1944 int32_t first_tile_id = 0; int32_t the_tile_count = 1;
1945 sprintf(firsttile,"%d",0);
1946 sprintf(tilecount,"%d",1);
1947 //int32_t ret;
1948
1949
1950
1951 save_tiles_dlg[0].dp2 = get_zc_font(font_lfont);
1952
1953 sprintf(firsttile,"%d",0);
1954 sprintf(tilecount,"%d",1);
1955
1956 save_tiles_dlg[5].dp = firsttile;
1957 save_tiles_dlg[7].dp = tilecount;
1958
1959 large_dialog(save_tiles_dlg);
1960
1961 int32_t ret = do_zqdialog(save_tiles_dlg,-1);
1962 jwin_center_dialog(save_tiles_dlg);
1963
1964 if(ret == 8)
1965 {
1966 first_tile_id = vbound(atoi(firsttile), 0, NEWMAXTILES);
1967 the_tile_count = vbound(atoi(tilecount), 1, NEWMAXTILES-first_tile_id);
1968 if(prompt_for_new_file_compat("Save ZTILE(.ztile)", "ztile", NULL,datapath,false))
1969 {
1970 char name[PATH_MAX];
1971 extract_name(temppath,name,FILENAMEALL);
1972 PACKFILE *f=pack_fopen_password(temppath,F_WRITE, "");
1973 if(f)
1974 {
1975 writetilefile(f,first_tile_id,the_tile_count);
1976 pack_fclose(f);
1977 char tmpbuf[PATH_MAX+20]={0};
1978 sprintf(tmpbuf,"Saved %s",name);
1979 jwin_alert("Success!",tmpbuf,NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
1980 }
1981 }
1982 }
1983 }
1984
1985 static DIALOG read_tiles_dlg[] =
1986 {
1987 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
1988
1989
1990 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Load Tilepack To:", NULL, NULL },
1991 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
1992 //for future tabs
1993 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
1994 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
1995 //4
1996 { jwin_text_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Starting at:", NULL, NULL },
1997 { jwin_edit_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
1998 //6
1999 { d_dummy_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
2000 { d_dummy_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2001 //8
2002 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Load", NULL, NULL },
2003 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2004 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2005 };
2006
2007
2008 void writesometiles_to(const char *prompt,int32_t initialval)
2009 {
2010
2011 char firsttile[8];;
2012 int32_t first_tile_id = 0; int32_t the_tile_count = 1;
2013 sprintf(firsttile,"%d",0);
2014 //int32_t ret;
2015
2016
2017
2018 read_tiles_dlg[0].dp2 = get_zc_font(font_lfont);
2019
2020 sprintf(firsttile,"%d",0);
2021 //sprintf(tilecount,"%d",1);
2022
2023 read_tiles_dlg[5].dp = firsttile;
2024
2025 large_dialog(read_tiles_dlg);
2026
2027 int32_t ret = do_zqdialog(read_tiles_dlg,-1);
2028 jwin_center_dialog(read_tiles_dlg);
2029
2030 if(ret == 8)
2031 {
2032 first_tile_id = vbound(atoi(firsttile), 0, NEWMAXTILES);
2033 //the_tile_count = vbound(atoi(tilecount), 1, NEWMAXTILES-first_tile_id);
2034 if(prompt_for_existing_file_compat("Load ZTILE(.ztile)", "ztile", NULL,datapath,false))
2035 {
2036
2037 char name[256];
2038 extract_name(temppath,name,FILENAMEALL);
2039 PACKFILE *f=pack_fopen_password(temppath,F_READ, "");
2040 if(f)
2041 {
2042
2043 if (!readtilefile_to_location(f,first_tile_id))
2044 {
2045 al_trace("Could not read from .ztile packfile %s\n", name);
2046 jwin_alert("ZTILE File: Error","Could not load the specified Tile.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2047 }
2048 else
2049 {
2050 jwin_alert("ZTILE File: Success!","Loaded the source tiles to your tile sheets!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2051 }
2052 pack_fclose(f);
2053 }
2054 }
2055 }
2056 }
2057
2058
2059 static DIALOG save_combofiles_dlg[] =
2060 {
2061 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
2062
2063
2064 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Save Combo Pack", NULL, NULL },
2065 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
2066 //for future tabs
2067 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2068 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2069 //4
2070 { jwin_text_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "First", NULL, NULL },
2071 { jwin_edit_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2072 //6
2073 { jwin_text_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
2074 { jwin_edit_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2075 //8
2076 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Save", NULL, NULL },
2077 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2078 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2079 };
2080
2081
2082 void savesomecombos(const char *prompt,int32_t initialval)
2083 {
2084
2085 char firsttile[8], tilecount[8];
2086 int32_t first_tile_id = 0; int32_t the_tile_count = 1;
2087 sprintf(firsttile,"%d",0);
2088 sprintf(tilecount,"%d",1);
2089 //int32_t ret;
2090
2091
2092
2093 save_combofiles_dlg[0].dp2 = get_zc_font(font_lfont);
2094
2095 sprintf(firsttile,"%d",0);
2096 sprintf(tilecount,"%d",1);
2097
2098 save_combofiles_dlg[5].dp = firsttile;
2099 save_combofiles_dlg[7].dp = tilecount;
2100
2101 large_dialog(save_combofiles_dlg);
2102
2103 int32_t ret = do_zqdialog(save_combofiles_dlg,-1);
2104 jwin_center_dialog(save_combofiles_dlg);
2105
2106 if(ret == 8)
2107 {
2108 first_tile_id = vbound(atoi(firsttile), 0, (MAXCOMBOS-1));
2109 the_tile_count = vbound(atoi(tilecount), 1, (MAXCOMBOS-1)-first_tile_id);
2110 if(prompt_for_new_file_compat("Save ZCOMBO(.zcombo)", "zcombo", NULL,datapath,false))
2111 {
2112 char name[PATH_MAX];
2113 extract_name(temppath,name,FILENAMEALL);
2114 PACKFILE *f=pack_fopen_password(temppath,F_WRITE, "");
2115 if(f)
2116 {
2117 writecombofile(f,first_tile_id,the_tile_count);
2118 pack_fclose(f);
2119 char tmpbuf[PATH_MAX+20]={0};
2120 sprintf(tmpbuf,"Saved %s",name);
2121 jwin_alert("Success!",tmpbuf,NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2122 }
2123 }
2124 }
2125 }
2126
2127
2128 static DIALOG load_comboset_dlg[] =
2129 {
2130 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
2131
2132
2133 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Combo Set (Range)", NULL, NULL },
2134 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
2135 //for future tabs
2136 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2137 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2138 //4
2139 { jwin_text_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "First:", NULL, NULL },
2140 { jwin_edit_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2141 //6
2142 { d_dummy_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
2143 { d_dummy_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2144 //8
2145 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Load", NULL, NULL },
2146 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2147 { jwin_check_proc, 10, 46, 95, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Don't Overwrite", NULL, NULL },
2148
2149 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2150 };
2151
2152 void writesomecombos(const char *prompt,int32_t initialval)
2153 {
2154
2155 char firsttile[8];
2156 int32_t first_tile_id = 0; int32_t the_tile_count = 1;
2157 sprintf(firsttile,"%d",0);
2158 //int32_t ret;
2159
2160
2161
2162 load_comboset_dlg[0].dp2 = get_zc_font(font_lfont);
2163
2164 sprintf(firsttile,"%d",0);
2165 //sprintf(tilecount,"%d",1);
2166
2167 load_comboset_dlg[5].dp = firsttile;
2168
2169 byte nooverwrite = 0;
2170
2171
2172 large_dialog(load_comboset_dlg);
2173
2174 int32_t ret = do_zqdialog(load_comboset_dlg,-1);
2175 jwin_center_dialog(load_comboset_dlg);
2176
2177 if(ret == 8)
2178 {
2179 if (load_comboset_dlg[10].flags & D_SELECTED) nooverwrite = 1;
2180
2181 al_trace("Nooverwrite is: %d\n", nooverwrite);
2182 first_tile_id = vbound(atoi(firsttile), 0, (MAXCOMBOS-1));
2183 //the_tile_count = vbound(atoi(tilecount), 1, NEWMAXTILES-first_tile_id);
2184 if(prompt_for_existing_file_compat("Load ZCOMBO(.zcombo)", "zcombo", NULL,datapath,false))
2185 {
2186 char name[256];
2187 extract_name(temppath,name,FILENAMEALL);
2188 PACKFILE *f=pack_fopen_password(temppath,F_READ, "");
2189 if(f)
2190 {
2191
2192 if (!readcombofile(f,first_tile_id,nooverwrite))
2193 {
2194 al_trace("Could not read from .zcombo packfile %s\n", name);
2195 jwin_alert("ZCOMBO File: Error","Could not load the specified combos.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2196 }
2197 else
2198 {
2199 jwin_alert("ZCOMBO File: Success!","Loaded the source combos to your combo pages!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2200 mark_save_dirty();
2201 }
2202 pack_fclose(f);
2203 }
2204
2205 }
2206 }
2207 }
2208
2209 static DIALOG load_combopack_dlg[] =
2210 {
2211 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
2212
2213
2214 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Import Full Combo Package 1:1", NULL, NULL },
2215 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
2216 //for future tabs
2217 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2218 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2219 //4
2220 { d_dummy_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Starting at:", NULL, NULL },
2221 { d_dummy_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2222 //6
2223 { d_dummy_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
2224 { d_dummy_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2225 //8
2226 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Load", NULL, NULL },
2227 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2228 { jwin_check_proc, 10, 42, 95, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Don't Overwrite", NULL, NULL },
2229
2230 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2231 };
2232
2233 void loadcombopack(const char *prompt,int32_t initialval)
2234 {
2235
2236 char firsttile[8];
2237 int32_t first_tile_id = 0; int32_t the_tile_count = 1;
2238 sprintf(firsttile,"%d",0);
2239 //int32_t ret;
2240
2241
2242
2243 load_combopack_dlg[0].dp2 = get_zc_font(font_lfont);
2244
2245 sprintf(firsttile,"%d",0);
2246 //sprintf(tilecount,"%d",1);
2247
2248 load_combopack_dlg[5].dp = firsttile;
2249
2250 byte nooverwrite = 0;
2251
2252
2253 large_dialog(load_combopack_dlg);
2254
2255 int32_t ret = do_zqdialog(load_combopack_dlg,-1);
2256 jwin_center_dialog(load_combopack_dlg);
2257
2258 if(ret == 8)
2259 {
2260 if (load_combopack_dlg[10].flags & D_SELECTED) nooverwrite = 1;
2261
2262 al_trace("Nooverwrite is: %d\n", nooverwrite);
2263 first_tile_id = vbound(atoi(firsttile), 0, (MAXCOMBOS-1));
2264 //the_tile_count = vbound(atoi(tilecount), 1, NEWMAXTILES-first_tile_id);
2265 if(prompt_for_existing_file_compat("Load ZCOMBO(.zcombo)", "zcombo", NULL,datapath,false))
2266 {
2267 char name[256];
2268 extract_name(temppath,name,FILENAMEALL);
2269 PACKFILE *f=pack_fopen_password(temppath,F_READ, "");
2270 if(f)
2271 {
2272 //need dialogue here
2273 if (!readcombofile(f,0,nooverwrite))
2274 {
2275 al_trace("Could not read from .zcombo packfile %s\n", name);
2276 jwin_alert("ZCOMBO File: Error","Could not load the specified Tile.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2277 }
2278 else
2279 {
2280 jwin_alert("ZCOMBO File: Success!","Loaded the source combos to your combo pages!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2281 mark_save_dirty();
2282 }
2283 }
2284
2285 pack_fclose(f);
2286 }
2287 }
2288 }
2289
2290
2291 static DIALOG read_combopack_dlg[] =
2292 {
2293 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
2294
2295
2296 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Load Combos (Specific Dest)", NULL, NULL },
2297 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
2298 //for future tabs
2299 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2300 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2301 //4
2302 { jwin_text_proc, 10, 24, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Starting at:", NULL, NULL },
2303 { jwin_edit_proc, 55, 22, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2304 //6
2305 { d_dummy_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
2306 { d_dummy_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2307 //8
2308 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Load", NULL, NULL },
2309 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2310 //10
2311 { jwin_check_proc, 10, 58, 95, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Don't Overwrite", NULL, NULL },
2312 //11
2313 { jwin_text_proc, 10, 42, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Skip:", NULL, NULL },
2314 //12
2315 { jwin_edit_proc, 55, 40, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2316
2317 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2318 };
2319
2320
2321
2322 void writesomecombos_to(const char *prompt,int32_t initialval)
2323 {
2324
2325 char firsttile[8];
2326 char skiptile[8];
2327 int32_t first_tile_id = 0; int32_t the_tile_count = 1;
2328 sprintf(firsttile,"%d",0);
2329 //int32_t ret;
2330
2331
2332
2333 read_combopack_dlg[0].dp2 = get_zc_font(font_lfont);
2334
2335 sprintf(skiptile,"%d",0);
2336 //sprintf(tilecount,"%d",1);
2337
2338 read_combopack_dlg[5].dp = firsttile;
2339
2340 byte nooverwrite = 0;
2341 int32_t skipover = 0;
2342
2343 sprintf(skiptile,"%d",0);
2344 //sprintf(tilecount,"%d",1);
2345
2346 read_combopack_dlg[12].dp = skiptile;
2347
2348 large_dialog(read_combopack_dlg);
2349
2350 int32_t ret = do_zqdialog(read_combopack_dlg,-1);
2351 jwin_center_dialog(read_combopack_dlg);
2352
2353 if(ret == 8)
2354 {
2355 if (read_combopack_dlg[10].flags & D_SELECTED) nooverwrite = 1;
2356
2357 first_tile_id = vbound(atoi(firsttile), 0, (MAXCOMBOS-1));
2358 skipover = vbound(atoi(skiptile), 0, (MAXCOMBOS-1));
2359 al_trace("skipover is: %d\n", skipover);
2360 //skipover = vbound(skipover, 0, (MAXCOMBOS-1-skipover));
2361 //the_tile_count = vbound(atoi(tilecount), 1, NEWMAXTILES-first_tile_id);
2362 if(prompt_for_existing_file_compat("Load ZCOMBO(.zcombo)", "zcombo", NULL,datapath,false))
2363 {
2364 char name[256];
2365 extract_name(temppath,name,FILENAMEALL);
2366 PACKFILE *f=pack_fopen_password(temppath,F_READ, "");
2367 if(f)
2368 {
2369
2370 if (!readcombofile_to_location(f,first_tile_id,nooverwrite, skipover))
2371 {
2372 al_trace("Could not read from .zcombo packfile %s\n", name);
2373 jwin_alert("ZCOMBO File: Error","Could not load the specified combos.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2374 }
2375 else
2376 {
2377 jwin_alert("ZCOMBO File: Success!","Loaded the source combos to your combo pages!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2378 mark_save_dirty();
2379 }
2380 pack_fclose(f);
2381 }
2382
2383 }
2384 }
2385 }
2386
2387
2388
2389 static DIALOG save_dmaps_dlg[] =
2390 {
2391 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
2392
2393
2394 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Save DMaps (.zdmap)", NULL, NULL },
2395 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
2396 //for future tabs
2397 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2398 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2399 //4
2400 { jwin_text_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "First", NULL, NULL },
2401 { jwin_edit_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2402 //6
2403 { jwin_text_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Last", NULL, NULL },
2404 { jwin_edit_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2405 //8
2406 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Save", NULL, NULL },
2407 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2408 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2409 };
2410
2411
2412 void savesomedmaps(const char *prompt,int32_t initialval)
2413 {
2414
2415 char firstdmap[8], lastdmap[8];
2416 int32_t first_dmap_id = 0; int32_t last_dmap_id = 0;
2417 sprintf(firstdmap,"%d",0);
2418 sprintf(lastdmap,"%d",1);
2419 //int32_t ret;
2420
2421
2422
2423 save_dmaps_dlg[0].dp2 = get_zc_font(font_lfont);
2424
2425 sprintf(firstdmap,"%d",0);
2426 sprintf(lastdmap,"%d",0);
2427
2428 save_dmaps_dlg[5].dp = firstdmap;
2429 save_dmaps_dlg[7].dp = lastdmap;
2430
2431 large_dialog(save_dmaps_dlg);
2432
2433 int32_t ret = do_zqdialog(save_dmaps_dlg,-1);
2434 jwin_center_dialog(save_dmaps_dlg);
2435
2436 if(ret == 8)
2437 {
2438 first_dmap_id = vbound(atoi(firstdmap), 0, MAXDMAPS-1);
2439 last_dmap_id = vbound(atoi(lastdmap), 0, MAXDMAPS-1);
2440
2441 if ( last_dmap_id < first_dmap_id )
2442 {
2443 int32_t swap = last_dmap_id;
2444 last_dmap_id = first_dmap_id;
2445 first_dmap_id = swap;
2446 }
2447 if(!prompt_for_new_file_compat("Export DMaps (.zdmap)","zdmap",NULL,datapath,false))
2448
2449
2450 mark_save_dirty();
2451
2452 PACKFILE *f=pack_fopen_password(temppath,F_WRITE, "");
2453 if(f)
2454 {
2455 if(!writesomedmaps(f,first_dmap_id,last_dmap_id,MAXDMAPS))
2456 {
2457 char buf[PATH_MAX+20],name[PATH_MAX];
2458 extract_name(temppath,name,FILENAMEALL);
2459 sprintf(buf,"Unable to load %s",name);
2460 jwin_alert("Error",buf,NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2461 }
2462 else
2463 {
2464 char name[PATH_MAX];
2465 extract_name(temppath,name,FILENAMEALL);
2466 char tmpbuf[PATH_MAX+20]={0};
2467 sprintf(tmpbuf,"Saved %s",name);
2468 jwin_alert("Success!",tmpbuf,NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2469 }
2470 }
2471 pack_fclose(f);
2472 }
2473 }
2474
2475 static DIALOG save_comboaliasfiles_dlg[] =
2476 {
2477 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
2478
2479
2480 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Save Combo Alias Pack", NULL, NULL },
2481 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
2482 //for future tabs
2483 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2484 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2485 //4
2486 { jwin_text_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "First", NULL, NULL },
2487 { jwin_edit_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2488 //6
2489 { jwin_text_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
2490 { jwin_edit_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2491 //8
2492 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Save", NULL, NULL },
2493 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2494 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2495 };
2496
2497
2498 void savesomecomboaliases(const char *prompt,int32_t initialval)
2499 {
2500
2501 char firsttile[8], tilecount[8];
2502 int32_t first_tile_id = 0; int32_t the_tile_count = 1;
2503 sprintf(firsttile,"%d",0);
2504 sprintf(tilecount,"%d",1);
2505 //int32_t ret;
2506
2507
2508
2509 save_comboaliasfiles_dlg[0].dp2 = get_zc_font(font_lfont);
2510
2511 sprintf(firsttile,"%d",0);
2512 sprintf(tilecount,"%d",1);
2513
2514 save_comboaliasfiles_dlg[5].dp = firsttile;
2515 save_comboaliasfiles_dlg[7].dp = tilecount;
2516
2517 large_dialog(save_comboaliasfiles_dlg);
2518
2519 int32_t ret = do_zqdialog(save_comboaliasfiles_dlg,-1);
2520 jwin_center_dialog(save_comboaliasfiles_dlg);
2521
2522 if(ret == 8)
2523 {
2524 first_tile_id = vbound(atoi(firsttile), 0, (MAXCOMBOALIASES-1));
2525 the_tile_count = vbound(atoi(tilecount), 1, (MAXCOMBOALIASES-1)-first_tile_id);
2526 if(prompt_for_new_file_compat("Save ZALIAS(.zalias)", "zalias", NULL,datapath,false))
2527 {
2528 char name[PATH_MAX];
2529 extract_name(temppath,name,FILENAMEALL);
2530 PACKFILE *f=pack_fopen_password(temppath,F_WRITE, "");
2531 if(f)
2532 {
2533 writecomboaliasfile(f,first_tile_id,the_tile_count);
2534 pack_fclose(f);
2535 char tmpbuf[PATH_MAX+20]={0};
2536 sprintf(tmpbuf,"Saved %s",name);
2537 jwin_alert("Success!",tmpbuf,NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2538 }
2539 }
2540 }
2541 }
2542
2543
2544 static DIALOG read_comboaliaspack_dlg[] =
2545 {
2546 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
2547
2548
2549 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Load Combo Pack To:", NULL, NULL },
2550 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
2551 //for future tabs
2552 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2553 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2554 //4
2555 { jwin_text_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Starting at:", NULL, NULL },
2556 { jwin_edit_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2557 //6
2558 { d_dummy_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
2559 { d_dummy_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2560 //8
2561 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Load", NULL, NULL },
2562 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2563 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2564 };
2565
2566
2567 void writesomecomboaliases_to(const char *prompt,int32_t initialval)
2568 {
2569
2570 char firsttile[8];;
2571 int32_t first_tile_id = 0; int32_t the_tile_count = 1;
2572 sprintf(firsttile,"%d",0);
2573 //int32_t ret;
2574
2575
2576
2577 read_comboaliaspack_dlg[0].dp2 = get_zc_font(font_lfont);
2578
2579 sprintf(firsttile,"%d",0);
2580 //sprintf(tilecount,"%d",1);
2581
2582 read_comboaliaspack_dlg[5].dp = firsttile;
2583
2584 large_dialog(read_comboaliaspack_dlg);
2585
2586 int32_t ret = do_zqdialog(read_comboaliaspack_dlg,-1);
2587 jwin_center_dialog(read_comboaliaspack_dlg);
2588
2589 if(ret == 8)
2590 {
2591 first_tile_id = vbound(atoi(firsttile), 0, (MAXCOMBOALIASES-1));
2592 //the_tile_count = vbound(atoi(tilecount), 1, NEWMAXTILES-first_tile_id);
2593 if(prompt_for_existing_file_compat("Load ZALIAS(.zalias)", "zalias", NULL,datapath,false))
2594 {
2595 char name[256];
2596 extract_name(temppath,name,FILENAMEALL);
2597 PACKFILE *f=pack_fopen_password(temppath,F_READ, "");
2598 if(f)
2599 {
2600
2601 if (!readcomboaliasfile_to_location(f,first_tile_id))
2602 {
2603 al_trace("Could not read from .zcombo packfile %s\n", name);
2604 jwin_alert("ZALIAS File: Error","Could not load the specified combo aliases.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2605 }
2606 else
2607 {
2608 jwin_alert("ZALIAS File: Success!","Loaded the source combos to your combo alias table!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2609 mark_save_dirty();
2610 }
2611 pack_fclose(f);
2612 }
2613 }
2614 }
2615 }
2616
2617
2618
2619
2620 //Doorsets
2621
2622 static DIALOG save_doorset_dlg[] =
2623 {
2624 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
2625 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Save Doorset", NULL, NULL },
2626 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
2627 //for future tabs
2628 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2629 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2630 //4
2631 { jwin_text_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "First", NULL, NULL },
2632 { jwin_edit_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2633 //6
2634 { jwin_text_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
2635 { jwin_edit_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2636 //8
2637 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Save", NULL, NULL },
2638 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2639 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2640 };
2641
2642
2643 void do_exportdoorset(const char *prompt,int32_t initialval)
2644 {
2645 char firstdoor[8], doorct[8];
2646 int32_t first_doorset_id = 0; int32_t the_doorset_count = 1;
2647 sprintf(firstdoor,"%d",0);
2648 sprintf(doorct,"%d",1);
2649 //int32_t ret;
2650 save_doorset_dlg[0].dp2 = get_zc_font(font_lfont);
2651
2652 sprintf(firstdoor,"%d",0);
2653 sprintf(doorct,"%d",1);
2654
2655 save_doorset_dlg[5].dp = firstdoor;
2656 save_doorset_dlg[7].dp = doorct;
2657
2658 large_dialog(save_doorset_dlg);
2659
2660 int32_t ret = do_zqdialog(save_doorset_dlg,-1);
2661 jwin_center_dialog(save_doorset_dlg);
2662
2663 if(ret == 8) //OK
2664 {
2665 /* sanity bounds
2666 first_doorset_id = vbound(atoi(firstdoor), 0, (MAXCOMBOS-1));
2667 the_doorset_count = vbound(atoi(doorct), 1, (MAXCOMBOS-1)-first_doorset_id);
2668 */
2669 if(prompt_for_new_file_compat("Save ZDOORS(.zdoors)", "zdoors", NULL,datapath,false))
2670 {
2671 char name[256];
2672 extract_name(temppath,name,FILENAMEALL);
2673 PACKFILE *f=pack_fopen_password(temppath,F_WRITE, "");
2674 if(f)
2675 {
2676 writezdoorsets(f,first_doorset_id,the_doorset_count);
2677 pack_fclose(f);
2678 char tmpbuf[512]={0};
2679 sprintf(tmpbuf,"Saved %s",name);
2680 jwin_alert("Success!",tmpbuf,NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2681 }
2682 }
2683 }
2684 }
2685
2686 static DIALOG load_doorset_dlg[] =
2687 {
2688 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
2689 { jwin_win_proc, 0, 0, 120, 124, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Door Set (Range)", NULL, NULL },
2690 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
2691 //for future tabs
2692 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2693 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2694 //4
2695 { jwin_text_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "First:", NULL, NULL },
2696 { jwin_edit_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2697 //6
2698 { jwin_text_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
2699 { jwin_edit_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2700 //8
2701 { jwin_button_proc, 15, 92, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Load", NULL, NULL },
2702 { jwin_button_proc, 69, 92, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2703 //10
2704 { jwin_text_proc, 10, 64, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Dest", NULL, NULL },
2705 { jwin_edit_proc, 55, 63, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2706 //8
2707
2708 // { jwin_check_proc, 10, 46, 95, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Don't Overwrite", NULL, NULL },
2709
2710 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2711 };
2712
2713 void do_importdoorset(const char *prompt,int32_t initialval)
2714 {
2715
2716 char firstdoor[8], doorct[8], destid[8];
2717 int32_t first_doorset_id = 0; int32_t the_doorset_count = 1;
2718 int32_t the_dest_id = 0;
2719 sprintf(firstdoor,"%d",0);
2720 sprintf(doorct,"%d",1);
2721 sprintf(destid,"%d",0);
2722 //int32_t ret;
2723
2724 save_doorset_dlg[0].dp2 = get_zc_font(font_lfont);
2725
2726 load_doorset_dlg[5].dp = firstdoor;
2727 load_doorset_dlg[7].dp = doorct;
2728 load_doorset_dlg[11].dp = destid;
2729
2730 byte nooverwrite = 0;
2731
2732 large_dialog(load_doorset_dlg);
2733
2734 int32_t ret = do_zqdialog(load_doorset_dlg,-1);
2735 jwin_center_dialog(load_doorset_dlg);
2736
2737 if(ret == 8) //OK
2738 {
2739 //if (load_doorset_dlg[10].flags & D_SELECTED) nooverwrite = 1;
2740
2741 //sanity bound
2742 first_doorset_id = vbound(atoi(firstdoor), 0, door_combo_set_count);
2743 the_doorset_count = vbound(atoi(doorct), 1, door_combo_set_count);
2744 the_dest_id = vbound(atoi(destid), 0, door_combo_set_count);
2745 if(prompt_for_existing_file_compat("Load ZDOORS(.zdoors)", "zdoors", NULL,datapath,false))
2746 {
2747 char name[256];
2748 extract_name(temppath,name,FILENAMEALL);
2749 PACKFILE *f=pack_fopen_password(temppath,F_READ, "");
2750 if(f)
2751 {
2752 int32_t ret = readzdoorsets(f,first_doorset_id,the_doorset_count, the_dest_id);
2753
2754 if (!ret)
2755 {
2756 al_trace("Could not read from .zdoors packfile %s\n", name);
2757 jwin_alert("ZDOORS File: Error","Could not load the specified doorsets.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2758 }
2759 else if ( ret == 1 )
2760 {
2761 jwin_alert("ZDOORS File: Success!","Loaded the source doorsets!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2762 mark_save_dirty();
2763 }
2764 else if ( ret == 2 )
2765 {
2766 jwin_alert("ZDOORS File: Issue:","Targets exceed doorset count!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2767 mark_save_dirty();
2768 }
2769 pack_fclose(f);
2770 }
2771 }
2772 }
2773 }
2774
2775 int32_t gettilepagenumber(const char *prompt, int32_t initialval)
2776 {
2777 char buf[20];
2778 sprintf(buf,"%d",initialval);
2779 getnum_dlg[0].dp=(void *)prompt;
2780 getnum_dlg[0].dp2=get_zc_font(font_lfont);
2781 getnum_dlg[2].dp=buf;
2782
2783 large_dialog(getnum_dlg);
2784
2785 int32_t ret = do_zqdialog(getnum_dlg,2);
2786
2787 if(ret==3)
2788 return atoi(buf);
2789
2790 return -1;
2791 }
2792
2793 int32_t gethexnumber(const char *prompt,int32_t initialval)
2794 {
2795 cancelgetnum=true;
2796 char buf[20];
2797 sprintf(buf,"%X",initialval);
2798 getnum_dlg[0].dp=(void *)prompt;
2799 getnum_dlg[0].dp2=get_zc_font(font_lfont);
2800 getnum_dlg[2].dp=(void *)buf;
2801
2802 large_dialog(getnum_dlg);
2803
2804 int32_t ret=do_zqdialog(getnum_dlg,2);
2805
2806 if(ret!=0&&ret!=4)
2807 {
2808 cancelgetnum=false;
2809 }
2810
2811 if(ret==3)
2812 return zc_xtoi(buf);
2813
2814 return initialval;
2815 }
2816
2817 void update_combo_cycling()
2818 {
2819 Map.update_combo_cycling();
2820 }
2821
2822 void update_freeform_combos()
2823 {
2824 Map.update_freeform_combos();
2825 }
2826
2827 bool layers_valid(mapscr *tempscr)
2828 {
2829 for(int32_t i=0; i<6; i++)
2830 {
2831 if(tempscr->layermap[i]>map_count)
2832 {
2833 return false;
2834 }
2835 }
2836
2837 return true;
2838 }
2839
2840 void fix_layers(mapscr *tempscr, bool showwarning)
2841 {
2842 char buf[80]="layers have been changed: ";
2843
2844 for(int32_t i=0; i<6; i++)
2845 {
2846 if(tempscr->layermap[i]>map_count)
2847 {
2848 strcat(buf, "%d ");
2849 sprintf(buf, buf, i+1);
2850 tempscr->layermap[i]=0;
2851 }
2852 }
2853
2854 if(showwarning)
2855 {
2856 jwin_alert("Invalid layers detected",
2857 "One or more layers on this screen used",
2858 "maps that do not exist. The settings of these",
2859 buf, "O&K", NULL, 'o', 0, get_zc_font(font_lfont));
2860 }
2861 }
2862
2863 extern const char *colorlist(int32_t index, int32_t *list_size);
2864
2865 static char autobackup_str_buf[32];
2866 const char *autobackuplist(int32_t index, int32_t *list_size)
2867 {
2868 if(index>=0)
2869 {
2870 bound(index,0,10);
2871
2872 if(index==0)
2873 {
2874 sprintf(autobackup_str_buf,"Disabled");
2875 }
2876 else
2877 {
2878 sprintf(autobackup_str_buf,"%2d",index);
2879 }
2880
2881 return autobackup_str_buf;
2882 }
2883
2884 *list_size=11;
2885 return NULL;
2886 }
2887
2888 static char autosave_str_buf[32];
2889 const char *autosavelist(int32_t index, int32_t *list_size)
2890 {
2891 if(index>=0)
2892 {
2893 bound(index,0,10);
2894
2895 if(index==0)
2896 {
2897 sprintf(autosave_str_buf,"Disabled");
2898 }
2899 else
2900 {
2901 sprintf(autosave_str_buf,"%2d Minute%c",index,index>1?'s':0);
2902 }
2903
2904 return autosave_str_buf;
2905 }
2906
2907 *list_size=11;
2908 return NULL;
2909 }
2910
2911 const char *autosavelist2(int32_t index, int32_t *list_size)
2912 {
2913 if(index>=0)
2914 {
2915 bound(index,0,9);
2916 sprintf(autosave_str_buf,"%2d",index+1);
2917 return autosave_str_buf;
2918 }
2919
2920 *list_size=10;
2921 return NULL;
2922 }
2923
2924
2925 static int32_t options_1_list[] =
2926 {
2927 // dialog control number
2928 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, -1
2929 };
2930
2931 static int32_t options_2_list[] =
2932 {
2933 // dialog control number
2934 50, 51, -1
2935 };
2936
2937 static int32_t options_3_list[] =
2938 {
2939 // dialog control number
2940 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, -1
2941 };
2942 static int32_t options_4_list[] =
2943 {
2944 57, 58, 59, 60,
2945 -1
2946 };
2947
2948 static TABPANEL options_tabs[] =
2949 {
2950 // (text)
2951 { (char *)" 1 ", D_SELECTED, options_1_list, 0, NULL },
2952 { (char *)" 2 ", 0, options_2_list, 0, NULL },
2953 { (char *)" 3 ", 0, options_3_list, 0, NULL },
2954 { (char *)" 4 ", 0, options_4_list, 0, NULL },
2955 { NULL, 0, NULL, 0, NULL }
2956 };
2957
2958 12 static ListData autobackup_list(autobackuplist, &font);
2959 12 static ListData autosave_list(autosavelist, &font);
2960 12 static ListData autosave_list2(autosavelist2, &font);
2961 12 static ListData color_list(colorlist, &font);
2962 12 static ListData snapshotformat_list(snapshotformatlist, &font);
2963
2964 const char *dm_names[dm_max]=
2965 {
2966 "Normal",
2967 "Relational", // Removed.
2968 "Dungeon", // Removed.
2969 "Alias",
2970 "Pool",
2971 "Auto"
2972 };
2973
2974 void fix_drawing_mode_menu()
2975 {
2976 drawing_mode_menu.select_only_uid(draw_mode);
2977 }
2978
2979 int32_t onDrawingMode()
2980 {
2981 draw_mode=(draw_mode+1)%dm_max;
2982 int dm_relational = 1;
2983 if ((int)draw_mode == dm_relational)
2984 draw_mode += 2;
2985 fix_drawing_mode_menu();
2986 restore_mouse();
2987 return D_O_K;
2988 }
2989
2990 int32_t onDrawingModeNormal()
2991 {
2992 draw_mode=dm_normal;
2993 fix_drawing_mode_menu();
2994 restore_mouse();
2995 return D_O_K;
2996 }
2997
2998 int32_t onDrawingModeAlias()
2999 {
3000 if(draw_mode==dm_alias)
3001 {
3002 return onDrawingModeNormal();
3003 }
3004
3005 draw_mode=dm_alias;
3006 alias_cset_mod=0;
3007 fix_drawing_mode_menu();
3008 restore_mouse();
3009 return D_O_K;
3010 }
3011
3012 int32_t onDrawingModePool()
3013 {
3014 if(draw_mode==dm_cpool)
3015 {
3016 return onDrawingModeNormal();
3017 }
3018
3019 draw_mode=dm_cpool;
3020 fix_drawing_mode_menu();
3021 restore_mouse();
3022 return D_O_K;
3023 }
3024
3025 int32_t onDrawingModeAuto()
3026 {
3027 if (draw_mode == dm_auto)
3028 {
3029 return onDrawingModeNormal();
3030 }
3031
3032 draw_mode = dm_auto;
3033 fix_drawing_mode_menu();
3034 restore_mouse();
3035 return D_O_K;
3036 }
3037
3038 int32_t onReTemplate()
3039 {
3040 if(jwin_alert("Confirm Overwrite","Apply NES Dungeon template to","all screens on this map?",NULL,"&Yes","&No",'y','n',get_zc_font(font_lfont))==1)
3041 {
3042 Map.TemplateAll();
3043 refresh(rALL);
3044 }
3045
3046 return D_O_K;
3047 }
3048
3049 int32_t onUndo()
3050 {
3051 Map.UndoCommand();
3052 refresh(rALL);
3053 return D_O_K;
3054 }
3055
3056 int32_t onRedo()
3057 {
3058 Map.RedoCommand();
3059 refresh(rALL);
3060 return D_O_K;
3061 }
3062
3063 int32_t onCopy()
3064 {
3065 if(prv_mode)
3066 {
3067 Map.set_prvcmb(Map.get_prvcmb()==0?1:0);
3068 return D_O_K;
3069 }
3070
3071 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
3072 Map.Copy(screen);
3073 return D_O_K;
3074 }
3075
3076 int32_t onPaste()
3077 {
3078 if(key[KEY_LSHIFT] || key[KEY_RSHIFT])
3079 {
3080 if(CHECK_CTRL_CMD)
3081 return onPasteAllToAll();
3082 else return onPasteAll();
3083 }
3084 else if(CHECK_CTRL_CMD)
3085 return onPasteToAll();
3086 else
3087 {
3088 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
3089 Map.DoPasteScreenCommand(PasteCommandType::ScreenPartial, screen);
3090 }
3091 return D_O_K;
3092 }
3093
3094 int32_t onPasteAll()
3095 {
3096 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
3097 Map.DoPasteScreenCommand(PasteCommandType::ScreenAll, screen);
3098 return D_O_K;
3099 }
3100
3101 int32_t onPasteToAll()
3102 {
3103 if(confirmBox("You are about to paste to all screens on the current map."))
3104 {
3105 Map.DoPasteScreenCommand(PasteCommandType::ScreenPartialToEveryScreen);
3106 }
3107 return D_O_K;
3108 }
3109
3110 int32_t onPasteAllToAll()
3111 {
3112 if(confirmBox("You are about to paste to all screens on the current map."))
3113 {
3114 Map.DoPasteScreenCommand(PasteCommandType::ScreenAllToEveryScreen);
3115 }
3116 return D_O_K;
3117 }
3118
3119 int32_t onPasteUnderCombo()
3120 {
3121 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
3122 Map.DoPasteScreenCommand(PasteCommandType::ScreenUnderCombo, screen);
3123 return D_O_K;
3124 }
3125
3126 int32_t onPasteSecretCombos()
3127 {
3128 Map.DoPasteScreenCommand(PasteCommandType::ScreenSecretCombos);
3129 return D_O_K;
3130 }
3131
3132 int32_t onPasteFFCombos()
3133 {
3134 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
3135 Map.DoPasteScreenCommand(PasteCommandType::ScreenFFCombos, screen);
3136 return D_O_K;
3137 }
3138
3139 int32_t onPasteWarps()
3140 {
3141 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
3142 Map.DoPasteScreenCommand(PasteCommandType::ScreenWarps, screen);
3143 return D_O_K;
3144 }
3145
3146 int32_t onPasteScreenData()
3147 {
3148 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
3149 Map.DoPasteScreenCommand(PasteCommandType::ScreenData, screen);
3150 return D_O_K;
3151 }
3152
3153 int32_t onPasteWarpLocations()
3154 {
3155 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
3156 Map.DoPasteScreenCommand(PasteCommandType::ScreenWarpLocations, screen);
3157 return D_O_K;
3158 }
3159
3160 int32_t onPasteDoors()
3161 {
3162 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
3163 Map.DoPasteScreenCommand(PasteCommandType::ScreenDoors, screen);
3164 return D_O_K;
3165 }
3166
3167 int32_t onPasteLayers()
3168 {
3169 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
3170 Map.DoPasteScreenCommand(PasteCommandType::ScreenLayers, screen);
3171 return D_O_K;
3172 }
3173
3174 int32_t onPastePalette()
3175 {
3176 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
3177 Map.DoPasteScreenCommand(PasteCommandType::ScreenPalette, screen);
3178 return D_O_K;
3179 }
3180
3181 int32_t onPasteRoom()
3182 {
3183 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
3184 Map.DoPasteScreenCommand(PasteCommandType::ScreenRoom, screen);
3185 return D_O_K;
3186 }
3187
3188 int32_t onPasteGuy()
3189 {
3190 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
3191 Map.DoPasteScreenCommand(PasteCommandType::ScreenGuy, screen);
3192 return D_O_K;
3193 }
3194
3195 int32_t onPasteEnemies()
3196 {
3197 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
3198 Map.DoPasteScreenCommand(PasteCommandType::ScreenEnemies, screen);
3199 return D_O_K;
3200 }
3201
3202 int32_t onDelete()
3203 {
3204 restore_mouse();
3205
3206 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
3207 mapscr* scr = active_visible_screen ? active_visible_screen->scr : Map.CurrScr();
3208 if(!(scr->valid&mVALID) || jwin_alert("Confirm Delete","Delete this screen?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3209 {
3210 Map.DoClearScreenCommand(screen);
3211 }
3212
3213 mark_save_dirty();
3214 return D_O_K;
3215 }
3216
3217 int32_t onDeleteMap()
3218 {
3219 if(jwin_alert("Confirm Delete","Clear this entire map?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3220 {
3221 Map.clearmap(false);
3222 refresh(rALL);
3223 mark_save_dirty();
3224 }
3225
3226 return D_O_K;
3227 }
3228
3229 int32_t onToggleDarkness()
3230 {
3231 Map.CurrScr()->flags^=4;
3232 refresh(rMAP+rMENU);
3233 mark_save_dirty();
3234 return D_O_K;
3235 }
3236
3237 int32_t onIncMap()
3238 {
3239 int32_t m=Map.getCurrMap();
3240 Map.setCurrMap(m+1>=map_count?0:m+1);
3241 Map.setlayertarget(); //Needed to refresh the screen info. -Z ( 26th March, 2019 )
3242
3243 refresh(rALL);
3244 return D_O_K;
3245 }
3246
3247 int32_t onDecMap()
3248 {
3249 int32_t m = Map.getCurrMap();
3250 Map.setCurrMap((m-1<0)?map_count-1:zc_min(m-1,map_count-1));
3251 // Map.setCurrScr(Map.getCurrScr()); //Needed to refresh the screen info. -Z ( 26th March, 2019 )
3252 Map.setlayertarget(); //Needed to refresh the screen info. -Z ( 26th March, 2019 )
3253
3254 Map.refresh_color();
3255
3256 refresh(rALL);
3257 return D_O_K;
3258 }
3259
3260
3261 int32_t onDefault_Pals()
3262 {
3263 if(jwin_alert("Confirm Reset","Reset all palette data?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3264 {
3265 mark_save_dirty();
3266
3267 if(!init_colordata(true, &header, &QMisc))
3268 {
3269 jwin_alert("Error","Palette reset failed.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
3270 }
3271
3272 refresh_pal();
3273 }
3274
3275 return D_O_K;
3276 }
3277
3278 int32_t onDefault_Combos()
3279 {
3280 if(jwin_alert("Confirm Reset","Reset combo data?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3281 {
3282 mark_save_dirty();
3283
3284 if(!init_combos(true, &header))
3285 {
3286 jwin_alert("Error","Combo reset failed.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
3287 }
3288
3289 refresh(rALL);
3290 }
3291
3292 return D_O_K;
3293 }
3294
3295 int32_t onDefault_Items()
3296 {
3297 if(jwin_alert("Confirm Reset","Reset all items?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3298 {
3299 mark_save_dirty();
3300 reset_items(true, &header);
3301 }
3302
3303 return D_O_K;
3304 }
3305
3306 int32_t onDefault_Weapons()
3307 {
3308 if(jwin_alert("Confirm Reset","Reset weapon/misc. sprite data?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3309 {
3310 mark_save_dirty();
3311 reset_wpns(true, &header);
3312 }
3313
3314 return D_O_K;
3315 }
3316
3317 int32_t onDefault_Guys()
3318 {
3319 if(jwin_alert("Confirm Reset","Reset all enemy/NPC data?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3320 {
3321 mark_save_dirty();
3322 reset_guys();
3323 }
3324
3325 return D_O_K;
3326 }
3327
3328
3329 int32_t onDefault_Tiles()
3330 {
3331 if(jwin_alert("Confirm Reset","Reset all tiles?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3332 {
3333 mark_save_dirty();
3334
3335 if(!init_tiles(true, &header))
3336 {
3337 jwin_alert("Error","Tile reset failed.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
3338 }
3339
3340 refresh(rALL);
3341 }
3342
3343 return D_O_K;
3344 }
3345
3346 void change_sfx(SAMPLE *sfx1, SAMPLE *sfx2);
3347
3348 int32_t onDefault_SFX()
3349 {
3350 if(jwin_alert("Confirm Reset","Reset all sound effects?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3351 {
3352 mark_save_dirty();
3353 SAMPLE *temp_sample;
3354
3355 for(int32_t i=1; i<WAV_COUNT; i++)
3356 {
3357 temp_sample = (SAMPLE *)sfxdata[zc_min(i,Z35)].dat;
3358 change_sfx(&customsfxdata[i], temp_sample);
3359 sprintf(sfx_string[i],"s%03d",i);
3360
3361 if(i<Z35)
3362 strcpy(sfx_string[i], old_sfx_string[i-1]);
3363 set_bit(customsfxflag, i<Z35?1:0, i-1);
3364 }
3365 }
3366
3367 return D_O_K;
3368 }
3369
3370
3371 int32_t onDefault_MapStyles()
3372 {
3373 if(jwin_alert("Confirm Reset","Reset all map styles?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3374 {
3375 mark_save_dirty();
3376 reset_mapstyles(true, &QMisc);
3377 }
3378
3379 return D_O_K;
3380 }
3381
3382 int onScrollScreen(int dir, bool warp)
3383 {
3384 Map.scroll(dir,warp);
3385 return D_O_K;
3386 }
3387
3388 int32_t onComboColLeft()
3389 {
3390 if(draw_mode==dm_cpool||draw_mode==dm_auto)
3391 ;
3392 else if((First[current_combolist]>0)&&(draw_mode!=dm_alias))
3393 {
3394 First[current_combolist]-=1;
3395 clear_tooltip();
3396 refresh(rCOMBOS);
3397 }
3398 else if((combo_alistpos[current_comboalist]>0)&&(draw_mode==dm_alias))
3399 {
3400 combo_alistpos[current_comboalist]-=1;
3401 clear_tooltip();
3402 refresh(rCOMBOS);
3403 }
3404
3405 clear_keybuf();
3406 return D_O_K;
3407 }
3408
3409 int32_t onComboColRight()
3410 {
3411 auto& sqr = (draw_mode == dm_alias ? comboaliaslist[current_comboalist] : combolist[current_combolist]);
3412 if(draw_mode==dm_cpool||draw_mode==dm_auto)
3413 ;
3414 else if((First[current_combolist]<(MAXCOMBOS-(sqr.w*sqr.h)))&&(draw_mode!=dm_alias))
3415 {
3416 First[current_combolist]+=1;
3417 clear_tooltip();
3418 refresh(rCOMBOS);
3419 }
3420 else if((combo_alistpos[current_comboalist]<(MAXCOMBOALIASES-(sqr.w*sqr.h)))&&(draw_mode==dm_alias))
3421 {
3422 combo_alistpos[current_comboalist]+=1;
3423 clear_tooltip();
3424 refresh(rCOMBOS);
3425 }
3426
3427 clear_keybuf();
3428 return D_O_K;
3429 }
3430
3431 int32_t onComboColUp()
3432 {
3433 auto& sqr = (draw_mode == dm_alias ? comboaliaslist[current_comboalist] : combolist[current_combolist]);
3434 if(draw_mode==dm_cpool||draw_mode==dm_auto)
3435 ;
3436 else if((First[current_combolist]>0)&&(draw_mode!=dm_alias))
3437 {
3438 First[current_combolist]-=zc_min(First[current_combolist],sqr.w);
3439 clear_tooltip();
3440
3441 refresh(rCOMBOS);
3442 }
3443 else if((combo_alistpos[current_comboalist]>0)&&(draw_mode==dm_alias))
3444 {
3445 combo_alistpos[current_comboalist]-=zc_min(combo_alistpos[current_comboalist],sqr.w);
3446 clear_tooltip();
3447 refresh(rCOMBOS);
3448 }
3449
3450 clear_keybuf();
3451 return D_O_K;
3452 }
3453
3454 int32_t onComboColDown()
3455 {
3456 auto& sqr = (draw_mode == dm_alias ? comboaliaslist[current_comboalist] : combolist[current_combolist]);
3457
3458 if(draw_mode==dm_cpool||draw_mode==dm_auto)
3459 ;
3460 else if((First[current_combolist]<(MAXCOMBOS-(sqr.w*sqr.h)))&&(draw_mode!=dm_alias))
3461 {
3462 First[current_combolist]+=zc_min((MAXCOMBOS-sqr.w)-First[current_combolist],sqr.w);
3463 clear_tooltip();
3464 refresh(rCOMBOS);
3465 }
3466 else if((combo_alistpos[current_comboalist]<(MAXCOMBOALIASES-(comboaliaslist[0].w*comboaliaslist[0].h)))&&(draw_mode==dm_alias))
3467 {
3468 combo_alistpos[current_comboalist]+=zc_min((MAXCOMBOALIASES-sqr.w)-combo_alistpos[current_comboalist],sqr.w);
3469 clear_tooltip();
3470 refresh(rCOMBOS);
3471 }
3472
3473 clear_keybuf();
3474 return D_O_K;
3475 }
3476
3477 void scrollup(int j)
3478 {
3479 switch(draw_mode)
3480 {
3481 case dm_alias:
3482 {
3483 auto& sqr = comboaliaslist[j];
3484 if(combo_alistpos[j]>0)
3485 {
3486 if(CHECK_CTRL_CMD)
3487 {
3488 combo_alistpos[j]=0;
3489 clear_tooltip();
3490 }
3491 else
3492 {
3493 combo_alistpos[j]-=zc_min(combo_alistpos[j],(sqr.w*sqr.h));
3494 clear_tooltip();
3495 }
3496
3497 refresh(rCOMBOS);
3498 }
3499 break;
3500 }
3501 case dm_cpool:
3502 {
3503 auto& sqr = comboaliaslist[j];
3504 if(combo_pool_listpos[j]>0)
3505 {
3506 if(CHECK_CTRL_CMD)
3507 {
3508 combo_pool_listpos[j]=0;
3509 clear_tooltip();
3510 }
3511 else
3512 {
3513 combo_pool_listpos[j]-=zc_min(combo_pool_listpos[j],(sqr.w*sqr.h));
3514 clear_tooltip();
3515 }
3516
3517 refresh(rCOMBOS);
3518 }
3519 break;
3520 }
3521 case dm_auto:
3522 {
3523 auto& sqr = comboaliaslist[j];
3524 if (combo_auto_listpos[j] > 0)
3525 {
3526 if (CHECK_CTRL_CMD)
3527 {
3528 combo_auto_listpos[j] = 0;
3529 clear_tooltip();
3530 }
3531 else
3532 {
3533 combo_auto_listpos[j] -= zc_min(combo_auto_listpos[j], (sqr.w * sqr.h));
3534 clear_tooltip();
3535 }
3536
3537 refresh(rCOMBOS);
3538 }
3539 break;
3540 }
3541 default:
3542 {
3543 auto& sqr = combolist[j];
3544 if(First[j]>0)
3545 {
3546 if(CHECK_CTRL_CMD)
3547 {
3548 First[j]-=zc_min(First[j],256);
3549 clear_tooltip();
3550 }
3551 else
3552 {
3553 First[j]-=zc_min(First[j],(sqr.w*sqr.h));
3554 clear_tooltip();
3555 }
3556
3557 refresh(rCOMBOS);
3558 }
3559 break;
3560 }
3561 }
3562 }
3563 void scrolldown(int j)
3564 {
3565 switch(draw_mode)
3566 {
3567 case dm_alias:
3568 {
3569 auto& sqr = comboaliaslist[j];
3570 if(combo_alistpos[j]<(MAXCOMBOALIASES-(sqr.w*sqr.h)))
3571 {
3572 if(CHECK_CTRL_CMD)
3573 {
3574 combo_alistpos[j]=MAXCOMBOALIASES-(sqr.w*sqr.h);
3575 clear_tooltip();
3576 }
3577 else
3578 {
3579 combo_alistpos[j]=zc_min((MAXCOMBOALIASES-(sqr.w*sqr.h)),combo_alistpos[j]+(sqr.w*sqr.h));
3580 clear_tooltip();
3581 }
3582
3583 refresh(rCOMBOS);
3584 }
3585 break;
3586 }
3587 case dm_cpool:
3588 {
3589 auto& sqr = comboaliaslist[j];
3590 if(combo_pool_listpos[j]<(MAXCOMBOALIASES-(sqr.w*sqr.h)))
3591 {
3592 if(CHECK_CTRL_CMD)
3593 {
3594 combo_pool_listpos[j]=MAXCOMBOALIASES-(sqr.w*sqr.h);
3595 clear_tooltip();
3596 }
3597 else
3598 {
3599 combo_pool_listpos[j]=zc_min((MAXCOMBOALIASES-(sqr.w*sqr.h)),combo_pool_listpos[j]+(sqr.w*sqr.h));
3600 clear_tooltip();
3601 }
3602
3603 refresh(rCOMBOS);
3604 }
3605 break;
3606 }
3607 case dm_auto:
3608 {
3609 auto& sqr = comboaliaslist[j];
3610 if (combo_auto_listpos[j] < (MAXCOMBOALIASES - (sqr.w * sqr.h)))
3611 {
3612 if (CHECK_CTRL_CMD)
3613 {
3614 combo_auto_listpos[j] = MAXCOMBOALIASES - (sqr.w * sqr.h);
3615 clear_tooltip();
3616 }
3617 else
3618 {
3619 combo_auto_listpos[j] = zc_min((MAXCOMBOALIASES - (sqr.w * sqr.h)), combo_pool_listpos[j] + (sqr.w * sqr.h));
3620 clear_tooltip();
3621 }
3622
3623 refresh(rCOMBOS);
3624 }
3625 break;
3626 }
3627 default:
3628 {
3629 auto& sqr = combolist[j];
3630 if(First[j]<(MAXCOMBOS-(sqr.w*sqr.h)))
3631 {
3632 if(CHECK_CTRL_CMD)
3633 {
3634 First[j]=zc_min((MAXCOMBOS-sqr.w*sqr.h),First[j]+256);
3635 clear_tooltip();
3636 }
3637 else
3638 {
3639 First[j]=zc_min((MAXCOMBOS-(sqr.w*sqr.h)),First[j]+(sqr.w*sqr.h));
3640 clear_tooltip();
3641 }
3642
3643 refresh(rCOMBOS);
3644 }
3645 break;
3646 }
3647 }
3648 }
3649
3650 int32_t onPgUp()
3651 {
3652 switch(draw_mode)
3653 {
3654 case dm_alias:
3655 scrollup(current_comboalist);
3656 break;
3657 case dm_cpool:
3658 scrollup(current_cpoollist);
3659 break;
3660 case dm_auto:
3661 scrollup(current_cautolist);
3662 break;
3663 default:
3664 scrollup(current_combolist);
3665 break;
3666 }
3667 return D_O_K;
3668 }
3669
3670 int32_t onPgDn()
3671 {
3672 switch(draw_mode)
3673 {
3674 case dm_alias:
3675 scrolldown(current_comboalist);
3676 break;
3677 case dm_cpool:
3678 scrolldown(current_cpoollist);
3679 break;
3680 case dm_auto:
3681 scrolldown(current_cautolist);
3682 break;
3683 default:
3684 scrolldown(current_combolist);
3685 break;
3686 }
3687 return D_O_K;
3688 }
3689
3690 int32_t onIncreaseCSet()
3691 {
3692 if(draw_mode!=dm_alias)
3693 {
3694 CSet=wrap(CSet+1,0,13);
3695 refresh(rCOMBOS+rMENU+rCOMBO);
3696 }
3697 else
3698 {
3699 alias_cset_mod=wrap(alias_cset_mod+1,0,13);
3700 }
3701 return D_O_K;
3702 }
3703
3704 int32_t onDecreaseCSet()
3705 {
3706 if(draw_mode!=dm_alias)
3707 {
3708 CSet=wrap(CSet-1,0,13);
3709 refresh(rCOMBOS+rMENU+rCOMBO);
3710 }
3711 else
3712 {
3713 alias_cset_mod=wrap(alias_cset_mod-1,0,13);
3714 }
3715 return D_O_K;
3716 }
3717
3718 int32_t onGotoPage()
3719 {
3720 if (draw_mode==dm_alias)
3721 {
3722 static const int PER_PAGE = 260;
3723 if(optional<int> v = call_get_num("Scroll to Alias Page", 0, MAXCOMBOALIASES/PER_PAGE-1, 0))
3724 combo_alistpos[current_comboalist] = *v*PER_PAGE;
3725 }
3726 else if (draw_mode==dm_cpool)
3727 {
3728 static const int PER_PAGE = 260;
3729 if(optional<int> v = call_get_num("Scroll to Combo Pool Page", 0, MAXCOMBOPOOLS/PER_PAGE-1, 0))
3730 combo_pool_listpos[current_cpoollist] = *v*PER_PAGE;
3731 }
3732 else if (draw_mode == dm_auto)
3733 {
3734 static const int PER_PAGE = 260;
3735 if(optional<int> v = call_get_num("Scroll to Auto Combo Page", 0, MAXAUTOCOMBOS/PER_PAGE-1, 0))
3736 combo_auto_listpos[current_cautolist] = *v*PER_PAGE;
3737 }
3738 else
3739 {
3740 static const int PER_PAGE = 256;
3741 if(optional<int> v = call_get_num("Scroll to Combo Page", 0, MAXCOMBOS/PER_PAGE-1, 0))
3742 First[current_combolist] = *v*PER_PAGE;
3743 }
3744
3745 return D_O_K;
3746 }
3747
3748 static char track_number_str_buf[MIDI_TRACK_BUFFER_SIZE] = {0};
3749 const char *tracknumlist(int32_t index, int32_t *list_size)
3750 {
3751 //memset(track_number_str_buf,0,50);
3752 if(index>=0)
3753 {
3754 bound(index,0,255);
3755 std::string name = zcmusic_get_track_name(zcmusic, index);
3756 sprintf(track_number_str_buf,"%02d %s",index+1, name.c_str());
3757 return track_number_str_buf;
3758 }
3759
3760 *list_size=zcmusic_get_tracks(zcmusic);
3761 return NULL;
3762 }
3763
3764 12 static ListData tracknum_list(tracknumlist, &font);
3765
3766 static DIALOG change_track_dlg[] =
3767 {
3768 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
3769 12 { jwin_win_proc, 60-12, 40, 200-16, 72, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Select Track", NULL, NULL },
3770 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
3771 12 { jwin_droplist_proc, 72-12, 60+4, 161, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &tracknum_list, NULL, NULL },
3772 12 { jwin_button_proc, 70, 87, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
3773 12 { jwin_button_proc, 150, 87, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
3774 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
3775 };
3776 // return list_dlg[2].d1;
3777
3778 int32_t changeTrack()
3779 {
3780 restore_mouse();
3781 change_track_dlg[0].dp2=get_zc_font(font_lfont);
3782 change_track_dlg[2].d1=gme_track;
3783
3784 large_dialog(change_track_dlg);
3785
3786 if(do_zqdialog(change_track_dlg,2)==3)
3787 {
3788 gme_track=change_track_dlg[2].d1;
3789 zcmusic_change_track(zcmusic, gme_track);
3790 }
3791
3792 return D_O_K;
3793 }
3794
3795 void set_media_tunes()
3796 {
3797 media_menu.select_uid(MENUID_MEDIA_TUNES, true);
3798 media_menu.select_uid(MENUID_MEDIA_PLAYMUSIC, false);
3799 disable_hotkey(ZQKEY_AMBIENT_MUSIC, false);
3800 disable_hotkey(ZQKEY_PLAY_MUSIC, false);
3801
3802 media_menu.disable_uid(MENUID_MEDIA_CHANGETRACK, true);
3803 disable_hotkey(ZQKEY_CHANGE_TRACK, true);
3804 }
3805
3806 int32_t playMusic()
3807 {
3808 char *ext;
3809 bool ismidi=false;
3810 char allmusic_types[256];
3811 sprintf(allmusic_types, "%s;mid", zcmusic_types);
3812
3813 if(prompt_for_existing_file_compat("Load Music",(char*)allmusic_types,NULL,midipath,false))
3814 {
3815 strcpy(midipath,temppath);
3816
3817 ext=get_extension(midipath);
3818
3819 if(
3820 (stricmp(ext,"ogg")==0)||
3821 (stricmp(ext,"mp3")==0)||
3822 (stricmp(ext,"it")==0)||
3823 (stricmp(ext,"xm")==0)||
3824 (stricmp(ext,"s3m")==0)||
3825 (stricmp(ext,"mod")==0)||
3826 (stricmp(ext,"spc")==0)||
3827 (stricmp(ext,"gym")==0)||
3828 (stricmp(ext,"nsf")==0)||
3829 (stricmp(ext,"gbs")==0)||
3830 (stricmp(ext,"vgm")==0)
3831 )
3832 {
3833 ismidi=false;
3834 }
3835 else if((stricmp(ext,"mid")==0))
3836 {
3837 ismidi=true;
3838 }
3839 else
3840 {
3841 return D_O_K;
3842 }
3843
3844 zc_stop_midi();
3845
3846 if(zcmusic != NULL)
3847 {
3848 zcmusic_stop(zcmusic);
3849 zcmusic_unload_file(zcmusic);
3850 zcmusic = NULL;
3851 zcmixer->newtrack = NULL;
3852 }
3853
3854 if(ismidi)
3855 {
3856 packfile_password("");
3857 if((song=load_midi(midipath))!=NULL)
3858 {
3859 if(zc_play_midi(song,true)==0)
3860 {
3861 media_menu.select_uid(MENUID_MEDIA_TUNES, false);
3862 media_menu.select_uid(MENUID_MEDIA_PLAYMUSIC, true);
3863 disable_hotkey(ZQKEY_AMBIENT_MUSIC, false);
3864 disable_hotkey(ZQKEY_PLAY_MUSIC, false);
3865
3866 media_menu.disable_uid(MENUID_MEDIA_CHANGETRACK, true);
3867 disable_hotkey(ZQKEY_CHANGE_TRACK, true);
3868 }
3869 }
3870 }
3871 else
3872 {
3873 gme_track=0;
3874 zcmusic = (ZCMUSIC*)zcmusic_load_file(midipath);
3875
3876 if(zcmusic!=NULL)
3877 {
3878 media_menu.select_uid(MENUID_MEDIA_TUNES, false);
3879 media_menu.select_uid(MENUID_MEDIA_PLAYMUSIC, true);
3880 disable_hotkey(ZQKEY_AMBIENT_MUSIC, false);
3881 disable_hotkey(ZQKEY_PLAY_MUSIC, false);
3882
3883 bool distrack = zcmusic_get_tracks(zcmusic)<2;
3884 media_menu.disable_uid(MENUID_MEDIA_CHANGETRACK, distrack);
3885 disable_hotkey(ZQKEY_CHANGE_TRACK, distrack);
3886
3887 zcmusic_play(zcmusic, midi_volume);
3888 }
3889 }
3890 }
3891
3892 return D_O_K;
3893 }
3894
3895 int32_t playZCForever()
3896 {
3897 stopMusic();
3898
3899 zcmusic = zcmusic_load_file("assets/zc/ZC_Forever_HD.mp3");
3900 if (zcmusic)
3901 {
3902 zcmusic_play(zcmusic, midi_volume);
3903 set_media_tunes();
3904 }
3905 return D_O_K;
3906 }
3907
3908 // It took awhile to get these values right, so no meddlin'!
3909 int32_t playTune1()
3910 {
3911 return playTune(0);
3912 }
3913 int32_t playTune2()
3914 {
3915 return playTune(81);
3916 }
3917 int32_t playTune3()
3918 {
3919 return playTune(233);
3920 }
3921 int32_t playTune4()
3922 {
3923 return playTune(553);
3924 }
3925 int32_t playTune5()
3926 {
3927 return playTune(814);
3928 }
3929 int32_t playTune6()
3930 {
3931 return playTune(985);
3932 }
3933 int32_t playTune7()
3934 {
3935 return playTune(1153);
3936 }
3937 int32_t playTune8()
3938 {
3939 return playTune(1333);
3940 }
3941 int32_t playTune9()
3942 {
3943 return playTune(1556);
3944 }
3945 int32_t playTune10()
3946 {
3947 return playTune(1801);
3948 }
3949 int32_t playTune11()
3950 {
3951 return playTune(2069);
3952 }
3953 int32_t playTune12()
3954 {
3955 return playTune(2189);
3956 }
3957 int32_t playTune13()
3958 {
3959 return playTune(2569);
3960 }
3961 int32_t playTune14()
3962 {
3963 return playTune(2753);
3964 }
3965 int32_t playTune15()
3966 {
3967 return playTune(2856);
3968 }
3969 int32_t playTune16()
3970 {
3971 return playTune(3042);
3972 }
3973 int32_t playTune17()
3974 {
3975 return playTune(3125);
3976 }
3977 int32_t playTune18()
3978 {
3979 return playTune(3217);
3980 }
3981 int32_t playTune19()
3982 {
3983 return playTune(3296);
3984 }
3985
3986 int32_t playTune(int32_t pos)
3987 {
3988 zc_stop_midi();
3989
3990 if(zcmusic != NULL)
3991 {
3992 zcmusic_stop(zcmusic);
3993 zcmusic_unload_file(zcmusic);
3994 zcmusic = NULL;
3995 zcmixer->newtrack = NULL;
3996 }
3997
3998 if(zc_play_midi(asset_tunes_midi,true)==0)
3999 {
4000 zc_midi_seek(pos);
4001 set_media_tunes();
4002 }
4003
4004 return D_O_K;
4005 }
4006
4007 int32_t stopMusic()
4008 {
4009 zc_stop_midi();
4010
4011 if(zcmusic != NULL)
4012 {
4013 zcmusic_stop(zcmusic);
4014 zcmusic_unload_file(zcmusic);
4015 zcmusic = NULL;
4016 zcmixer->newtrack = NULL;
4017 }
4018
4019 media_menu.select_uid(MENUID_MEDIA_TUNES, false);
4020 media_menu.select_uid(MENUID_MEDIA_PLAYMUSIC, false);
4021 disable_hotkey(ZQKEY_AMBIENT_MUSIC, false);
4022 disable_hotkey(ZQKEY_PLAY_MUSIC, false);
4023
4024 media_menu.disable_uid(MENUID_MEDIA_CHANGETRACK, true);
4025 disable_hotkey(ZQKEY_CHANGE_TRACK, true);
4026 return D_O_K;
4027 }
4028
4029 static int32_t gamemisc1_list[] =
4030 {
4031 5,6,7,8,
4032 9,10,11,12,
4033
4034 37,38,39,40,
4035 41,42,43,44,
4036
4037 71,72,73,74,
4038 75,76,77,78,
4039
4040 -1
4041 };
4042
4043 static int32_t gamemisc2_list[] =
4044 {
4045 13,14,15,16,
4046 17,18,19,20,
4047
4048 45,46,47,48,
4049 49,50,51,52,
4050
4051 79,80,81,82,
4052 83,84,85,86,
4053
4054 -1
4055 };
4056
4057 static int32_t gamemisc3_list[] =
4058 {
4059 21,22,23,24,
4060 25,26,27,28,
4061
4062 53,54,55,56,
4063 57,58,59,60,
4064
4065 87,88,89,90,
4066 91,92,93,94,
4067
4068 -1
4069 };
4070
4071 static int32_t gamemisc4_list[] =
4072 {
4073 29,30,31,32,
4074 33,34,35,36,
4075
4076 61,62,63,64,
4077 65,66,67,68,
4078
4079 95,96,97,98,
4080 99,100,101,102,
4081
4082 -1
4083 };
4084
4085 static TABPANEL gamemisc_tabs[] =
4086 {
4087 // (text)
4088 { (char *)" Misc[0-7] ", D_SELECTED, gamemisc1_list, 0, NULL },
4089 { (char *)" Misc[8-15] ", 0, gamemisc2_list, 0, NULL },
4090 { (char *)" Misc[16-23] ", 0, gamemisc3_list, 0, NULL },
4091 { (char *)" Misc[24-31] ", 0, gamemisc4_list, 0, NULL },
4092 { NULL, 0, NULL, 0, NULL }
4093 };
4094
4095 //to do: Make string boxes larger, and split into two tabs.
4096 static DIALOG gamemiscarray_dlg[] =
4097 {
4098 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
4099
4100 { jwin_win_proc, 0, 10, 310, 224, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Game->Misc[]", NULL, NULL },
4101 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4102 { jwin_tab_proc, 3, 26, 304, 174, vc(14), vc(1), 0, 0, 1, 0, (void *) gamemisc_tabs, NULL, (void *)gamemiscarray_dlg },
4103 { d_dummy_proc, 240, 144, 40, 8, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
4104 { d_dummy_proc, 240, 144, 40, 8, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
4105
4106 //5
4107 { jwin_edit_proc, 8, 42, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4108 { jwin_edit_proc, 8, 42+20, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4109 { jwin_edit_proc, 8, 42+40, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4110 //8
4111 { jwin_edit_proc, 8, 42+60, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4112 { jwin_edit_proc, 8, 42+80, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4113 { jwin_edit_proc, 8, 42+100, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4114 { jwin_edit_proc, 8, 42+120, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4115 { jwin_edit_proc, 8, 42+140, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4116 //13
4117 { jwin_edit_proc, 8, 42, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4118 { jwin_edit_proc, 8, 42+20, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4119 { jwin_edit_proc, 8, 42+40, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4120 { jwin_edit_proc, 8, 42+60, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4121 { jwin_edit_proc, 8, 42+80, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4122 //18
4123 { jwin_edit_proc, 8, 42+100, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4124 { jwin_edit_proc, 8, 42+120, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4125 { jwin_edit_proc, 8, 42+140, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4126 { jwin_edit_proc, 8, 42, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4127 { jwin_edit_proc, 8, 42+20, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4128 //23
4129 { jwin_edit_proc, 8, 42+40, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4130 { jwin_edit_proc, 8, 42+60, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4131 { jwin_edit_proc, 8, 42+80, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4132 { jwin_edit_proc, 8, 42+100, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4133 { jwin_edit_proc, 8, 42+120, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4134 //28
4135 { jwin_edit_proc, 8, 42+140, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4136 { jwin_edit_proc, 8, 42, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4137 { jwin_edit_proc, 8, 42+20, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4138 { jwin_edit_proc, 8, 42+40, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4139 { jwin_edit_proc, 8, 42+60, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4140 //33
4141 { jwin_edit_proc, 8, 42+80, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4142 { jwin_edit_proc, 8, 42+100, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4143 { jwin_edit_proc, 8, 42+120, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4144 { jwin_edit_proc, 8, 42+140, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4145 //37
4146 { jwin_numedit_swap_zsint_proc, 96, 42, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4147 { jwin_numedit_swap_zsint_proc, 96, 42+20, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4148 //39
4149 { jwin_numedit_swap_zsint_proc, 96, 42+40, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4150 { jwin_numedit_swap_zsint_proc, 96, 42+60, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4151 { jwin_numedit_swap_zsint_proc, 96, 42+80, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4152 { jwin_numedit_swap_zsint_proc, 96, 42+100, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4153 { jwin_numedit_swap_zsint_proc, 96, 42+120, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4154 //44
4155 { jwin_numedit_swap_zsint_proc, 96, 42+140, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4156 { jwin_numedit_swap_zsint_proc, 96, 42, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4157 { jwin_numedit_swap_zsint_proc, 96, 42+20, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4158
4159 { jwin_numedit_swap_zsint_proc, 96, 42+40, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4160 { jwin_numedit_swap_zsint_proc, 96, 42+60, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4161 //49
4162 { jwin_numedit_swap_zsint_proc, 96, 42+80, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4163 { jwin_numedit_swap_zsint_proc, 96, 42+100, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4164 { jwin_numedit_swap_zsint_proc, 96, 42+120, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4165 { jwin_numedit_swap_zsint_proc, 96, 42+140, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4166 { jwin_numedit_swap_zsint_proc, 96, 42, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4167 //54
4168 { jwin_numedit_swap_zsint_proc, 96, 42+20, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4169 { jwin_numedit_swap_zsint_proc, 96, 42+40, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4170 { jwin_numedit_swap_zsint_proc, 96, 42+60, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4171 { jwin_numedit_swap_zsint_proc, 96, 42+80, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4172 { jwin_numedit_swap_zsint_proc, 96, 42+100, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4173 //59
4174 { jwin_numedit_swap_zsint_proc, 96, 42+120, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4175 { jwin_numedit_swap_zsint_proc, 96, 42+140, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4176 { jwin_numedit_swap_zsint_proc, 96, 42, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4177 { jwin_numedit_swap_zsint_proc, 96, 42+20, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4178 { jwin_numedit_swap_zsint_proc, 96, 42+40, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4179 //64
4180 { jwin_numedit_swap_zsint_proc, 96, 42+60, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4181 { jwin_numedit_swap_zsint_proc, 96, 42+80, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4182 { jwin_numedit_swap_zsint_proc, 96, 42+100, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4183 { jwin_numedit_swap_zsint_proc, 96, 42+120, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4184 { jwin_numedit_swap_zsint_proc, 96, 42+140, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4185 //69
4186 { jwin_button_proc, 70, 204, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
4187 { jwin_button_proc, 170, 204, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
4188
4189 //71
4190 { jwin_swapbtn_proc, 156, 42, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4191 { jwin_swapbtn_proc, 156, 62, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4192 { jwin_swapbtn_proc, 156, 82, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4193 { jwin_swapbtn_proc, 156, 102, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4194 { jwin_swapbtn_proc, 156, 122, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4195 { jwin_swapbtn_proc, 156, 142, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4196 { jwin_swapbtn_proc, 156, 162, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4197 { jwin_swapbtn_proc, 156, 182, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4198 //79
4199 { jwin_swapbtn_proc, 156, 42, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4200 { jwin_swapbtn_proc, 156, 62, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4201 { jwin_swapbtn_proc, 156, 82, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4202 { jwin_swapbtn_proc, 156, 102, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4203 { jwin_swapbtn_proc, 156, 122, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4204 { jwin_swapbtn_proc, 156, 142, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4205 { jwin_swapbtn_proc, 156, 162, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4206 { jwin_swapbtn_proc, 156, 182, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4207 //87
4208 { jwin_swapbtn_proc, 156, 42, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4209 { jwin_swapbtn_proc, 156, 62, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4210 { jwin_swapbtn_proc, 156, 82, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4211 { jwin_swapbtn_proc, 156, 102, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4212 { jwin_swapbtn_proc, 156, 122, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4213 { jwin_swapbtn_proc, 156, 142, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4214 { jwin_swapbtn_proc, 156, 162, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4215 { jwin_swapbtn_proc, 156, 182, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4216 //95
4217 { jwin_swapbtn_proc, 156, 42, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4218 { jwin_swapbtn_proc, 156, 62, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4219 { jwin_swapbtn_proc, 156, 82, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4220 { jwin_swapbtn_proc, 156, 102, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4221 { jwin_swapbtn_proc, 156, 122, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4222 { jwin_swapbtn_proc, 156, 142, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4223 { jwin_swapbtn_proc, 156, 162, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4224 { jwin_swapbtn_proc, 156, 182, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4225
4226 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
4227 };
4228
4229 // +----------+
4230 // | |
4231 // | View Pic |
4232 // | |
4233 // | |
4234 // | |
4235 // +----------+
4236
4237 BITMAP *pic=NULL;
4238 BITMAP *bmap=NULL;
4239 PALETTE picpal;
4240 PALETTE mappal;
4241 int32_t picx=0,picy=0,mapx=0,mapy=0,pblack,pwhite;
4242
4243 double picscale=1.0,mapscale=1.0;
4244 bool vp_showpal=true, vp_showsize=true, vp_center=true;
4245
4246 //INLINE int32_t pal_sum(RGB p) { return p.r + p.g + p.b; }
4247
4248 void get_bw(RGB *pal,int32_t &black,int32_t &white)
4249 {
4250 black=white=1;
4251
4252 for(int32_t i=1; i<256; i++)
4253 {
4254 if(pal_sum(pal[i])<pal_sum(pal[black]))
4255 black=i;
4256
4257 if(pal_sum(pal[i])>pal_sum(pal[white]))
4258 white=i;
4259 }
4260 }
4261
4262 void draw_bw_mouse(int32_t white, int32_t old_mouse, int32_t new_mouse)
4263 {
4264 blit(mouse_bmp[old_mouse][0],mouse_bmp[new_mouse][0],0,0,0,0,16,16);
4265
4266 for(int32_t y=0; y<16; y++)
4267 {
4268 for(int32_t x=0; x<16; x++)
4269 {
4270 if(getpixel(mouse_bmp[new_mouse][0],x,y)!=0)
4271 {
4272 putpixel(mouse_bmp[new_mouse][0],x,y,white);
4273 }
4274 }
4275 }
4276 }
4277
4278 int32_t load_the_pic(BITMAP **dst, PALETTE dstpal)
4279 {
4280 PALETTE temppal;
4281
4282 for(int32_t i=0; i<256; i++)
4283 {
4284 temppal[i]=dstpal[i];
4285 dstpal[i]=RAMpal[i];
4286 }
4287
4288 // set up the new palette
4289 for(int32_t i=0; i<64; i++)
4290 {
4291 dstpal[i].r = i;
4292 dstpal[i].g = i;
4293 dstpal[i].b = i;
4294 }
4295
4296 zc_set_palette(dstpal);
4297
4298 BITMAP *graypic = create_bitmap_ex(8,screen->w,screen->h);
4299 int32_t _w = screen->w-1;
4300 int32_t _h = screen->h-1;
4301
4302 // gray scale the current frame
4303 for(int32_t y=0; y<_h; y++)
4304 {
4305 for(int32_t x=0; x<_w; x++)
4306 {
4307 int32_t c = screen->line[y][x];
4308 int32_t gray = zc_min((temppal[c].r*42 + temppal[c].g*75 + temppal[c].b*14) >> 7, 63);
4309 graypic->line[y][x] = gray;
4310 }
4311 }
4312
4313 blit(graypic,screen,0,0,0,0,screen->w,screen->h);
4314 destroy_bitmap(graypic);
4315 #ifdef __GNUC__
4316 #pragma GCC diagnostic ignored "-Wformat-overflow"
4317 #endif
4318 char extbuf[2][80];
4319 memset(extbuf[0],0,80);
4320 memset(extbuf[1],0,80);
4321 sprintf(extbuf[0], "View Image (%s", snapshotformat_str[0][1]);
4322 strcpy(extbuf[1], snapshotformat_str[0][1]);
4323
4324 for(int32_t i=1; i<ssfmtMAX; ++i)
4325 {
4326 sprintf(extbuf[0], "%s, %s", extbuf[0], snapshotformat_str[i][1]);
4327 sprintf(extbuf[1], "%s;%s", extbuf[1], snapshotformat_str[i][1]);
4328 }
4329
4330 sprintf(extbuf[0], "%s)", extbuf[0]);
4331 #ifdef __GNUC__
4332 #pragma GCC diagnostic pop
4333 #endif
4334
4335 int32_t gotit = prompt_for_existing_file_compat(extbuf[0],extbuf[1],NULL,imagepath,true);
4336
4337 if(!gotit)
4338 {
4339 zc_set_palette(temppal);
4340 get_palette(dstpal);
4341 return 1;
4342 }
4343
4344 strcpy(imagepath,temppath);
4345
4346 if(*dst)
4347 {
4348 destroy_bitmap(*dst);
4349 }
4350
4351 for(int32_t i=0; i<256; i++)
4352 {
4353 dstpal[i].r = 0;
4354 dstpal[i].g = 0;
4355 dstpal[i].b = 0;
4356 }
4357
4358 *dst = load_bitmap(imagepath,picpal);
4359
4360 if(!*dst)
4361 {
4362 jwin_alert("Error","Error loading image:",imagepath,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4363 return 2;
4364 }
4365
4366 // get_bw(picpal,pblack,pwhite);
4367 // draw_bw_mouse(pwhite);
4368 // gui_bg_color = pblack;
4369 // gui_fg_color = pwhite;
4370
4371 if(vp_center)
4372 {
4373 picx=picy=0;
4374 }
4375 else
4376 {
4377 picx=(*dst)->w-zq_screen_w;
4378 picy=(*dst)->h-zq_screen_h;
4379 }
4380
4381 return 0;
4382 }
4383 int load_the_pic_new(BITMAP **dst, PALETTE dstpal)
4384 {
4385 #ifdef __GNUC__
4386 #pragma GCC diagnostic ignored "-Wformat-overflow"
4387 #endif
4388 char extbuf[2][80];
4389 memset(extbuf[0],0,80);
4390 memset(extbuf[1],0,80);
4391 sprintf(extbuf[0], "View Image (%s", snapshotformat_str[0][1]);
4392 strcpy(extbuf[1], snapshotformat_str[0][1]);
4393
4394 for(int32_t i=1; i<ssfmtMAX; ++i)
4395 {
4396 sprintf(extbuf[0], "%s, %s", extbuf[0], snapshotformat_str[i][1]);
4397 sprintf(extbuf[1], "%s;%s", extbuf[1], snapshotformat_str[i][1]);
4398 }
4399
4400 sprintf(extbuf[0], "%s)", extbuf[0]);
4401 #ifdef __GNUC__
4402 #pragma GCC diagnostic pop
4403 #endif
4404
4405 int32_t gotit = prompt_for_existing_file_compat(extbuf[0],extbuf[1],NULL,imagepath,true);
4406
4407 if(!gotit)
4408 return 1;
4409
4410 strcpy(imagepath,temppath);
4411
4412 if(*dst)
4413 destroy_bitmap(*dst);
4414
4415 for(int32_t i=0; i<256; i++)
4416 {
4417 dstpal[i].r = 0;
4418 dstpal[i].g = 0;
4419 dstpal[i].b = 0;
4420 }
4421
4422 *dst = load_bitmap(imagepath,dstpal);
4423
4424 if(!*dst)
4425 {
4426 jwin_alert("Error","Error loading image:",imagepath,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4427 return 2;
4428 }
4429
4430 if(vp_center)
4431 {
4432 picx=picy=0;
4433 }
4434 else
4435 {
4436 picx=(*dst)->w-zq_screen_w;
4437 picy=(*dst)->h-zq_screen_h;
4438 }
4439
4440 return 0;
4441 }
4442
4443 int32_t saveMapAsImage(ALLEGRO_BITMAP* bitmap)
4444 {
4445 char buf[200];
4446 int32_t num=0;
4447
4448 do
4449 {
4450 snprintf(buf, 200, "%szquest_map%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
4451 buf[199]='\0';
4452 }
4453 while(num<99999 && exists(buf));
4454
4455 if (!al_save_bitmap(buf, bitmap))
4456 InfoDialog("Error", "Failed to save map image").show();
4457
4458 return D_O_K;
4459 }
4460
4461 int32_t onViewPic()
4462 {
4463 return launchPicViewer(&pic,picpal,picx,picy,picscale,false);
4464 }
4465
4466 int32_t launchPicViewer(BITMAP **pictoview, PALETTE pal, int32_t& px2, int32_t& py2, double& scale, bool isviewingmap, bool skipmenu)
4467 {
4468 restore_mouse();
4469 BITMAP *buf;
4470 bool done=false, redraw=true;
4471
4472 popup_zqdialog_start();
4473
4474 // Always call load_the_map() when viewing the map.
4475 if((!*pictoview || isviewingmap) && (isviewingmap ? load_the_map(skipmenu) : load_the_pic(pictoview,pal)))
4476 {
4477 zc_set_palette(RAMpal);
4478 popup_zqdialog_end();
4479 mapview_close();
4480 return D_O_K;
4481 }
4482
4483 MapViewRTI* rti_map_view = mapview_get_rti();
4484
4485 zq_freeze_all_rti();
4486 if (isviewingmap)
4487 rti_map_view->freeze = false;
4488 else
4489 get_screen_rti()->freeze = false;
4490
4491 get_bw(pal,pblack,pwhite);
4492
4493 int32_t oldfgcolor = gui_fg_color;
4494 int32_t oldbgcolor = gui_bg_color;
4495
4496 buf = create_bitmap_ex(8,zq_screen_w,zq_screen_h);
4497
4498 if(!buf)
4499 {
4500 jwin_alert("Error","Error creating temp bitmap",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4501 popup_zqdialog_end();
4502 mapview_close();
4503 return D_O_K;
4504 }
4505
4506 static LegacyBitmapRTI viewer_overlay_rti("viewer_overlay");
4507 viewer_overlay_rti.set_size(buf->w, buf->h);
4508 viewer_overlay_rti.a4_bitmap = buf;
4509 viewer_overlay_rti.transparency_index = 15;
4510 viewer_overlay_rti.freeze = false;
4511 get_root_rti()->add_child(&viewer_overlay_rti);
4512
4513 zc_set_palette(pal);
4514
4515 if(isviewingmap)
4516 {
4517 set_center_root_rti(false);
4518
4519 int sw = rti_map_view->width / 16;
4520 int sh = rti_map_view->height / 8;
4521 int screen = Map.getCurrScr();
4522 if (screen >= 0x00 && screen <= 0x7F)
4523 {
4524 auto root_transform = get_root_rti()->get_transform();
4525 int dw = al_get_display_width(all_get_display()) / root_transform.xscale;
4526 int dh = al_get_display_height(all_get_display()) / root_transform.yscale;
4527 mapx = (-(screen % 16) * sw - sw/2 + dw/2);
4528 mapy = (-(screen / 16) * sh - sh/2 + dh/2);
4529 }
4530 }
4531
4532 const double MIN_SCALE = 0.1;
4533 const double MAX_SCALE = 5.0;
4534 auto mouse_x = gui_mouse_x();
4535 auto mouse_y = gui_mouse_y();
4536 int mouse_off_x = 0, mouse_off_y = 0;
4537 double old_scale = scale;
4538 bool mouse_down = false;
4539
4540 do
4541 {
4542 int w, h;
4543 if (isviewingmap)
4544 {
4545 w = rti_map_view->width;
4546 h = rti_map_view->height;
4547 }
4548 else
4549 {
4550 w = (*pictoview)->w;
4551 h = (*pictoview)->h;
4552 }
4553
4554 if (isviewingmap)
4555 {
4556 auto root_transform = get_root_rti()->get_transform();
4557 int dw = al_get_display_width(all_get_display()) / root_transform.xscale;
4558 int dh = al_get_display_height(all_get_display()) / root_transform.yscale;
4559 mapx = std::max(mapx, (int)(-w*scale + dw));
4560 mapy = std::max(mapy, (int)(-h*scale + dh));
4561 mapx = std::min(mapx, 0);
4562 mapy = std::min(mapy, 0);
4563 rti_map_view->set_transform({mapx, mapy, (float)scale, (float)scale});
4564 }
4565
4566 if(redraw)
4567 {
4568 clear_to_color(buf,15);
4569
4570 if (!isviewingmap)
4571 stretch_blit(*pictoview, buf, 0, 0, w, h,
4572 int32_t(zq_screen_w + (px2 - w) * scale) / 2, int32_t(zq_screen_h + (py2 - h) * scale) / 2,
4573 int32_t(w * scale), int32_t(h * scale));
4574
4575 if(vp_showpal)
4576 for(int32_t i=0; i<256; i++)
4577 rectfill(buf,((i&15)<<2)+zq_screen_w-64,((i>>4)<<2)+zq_screen_h-64,((i&15)<<2)+zq_screen_w-64+3,((i>>4)<<2)+zq_screen_h-64+3,i);
4578
4579 if(vp_showsize)
4580 {
4581 textprintf_ex(buf,font,0,zq_screen_h-8,pwhite,pblack,"%dx%d %.2f%%",w,h,scale*100.0);
4582 }
4583
4584 if (!isviewingmap)
4585 blit(buf,screen,0,0,0,0,zq_screen_w,zq_screen_h);
4586 redraw=false;
4587 }
4588
4589 custom_vsync();
4590
4591 int32_t step = 16;
4592 double scale_step = 0.95;
4593 double scale_bigstep = 2.0;
4594
4595 if(scale < 1.0)
4596 step = int32_t(4.0/ scale);
4597
4598 bool shift = (key[KEY_LSHIFT] || key[KEY_RSHIFT]);
4599 bool ctrl = CHECK_CTRL_CMD;
4600 if (shift)
4601 step <<= 2;
4602 if (ctrl)
4603 step >>= 1;
4604 if (shift && ctrl)
4605 {
4606 scale_step = 0.90;
4607 scale_bigstep = 4.0;
4608 }
4609 else if (shift)
4610 {
4611 scale_step = 0.80;
4612 scale_bigstep = 3.0;
4613 }
4614 else if(ctrl)
4615 {
4616 scale_step = 0.975;
4617 scale_bigstep = 1.5;
4618 }
4619
4620 if(key[KEY_UP])
4621 {
4622 py2+=step;
4623 redraw=true;
4624 }
4625
4626 if(key[KEY_DOWN])
4627 {
4628 py2-=step;
4629 redraw=true;
4630 }
4631
4632 if(key[KEY_LEFT])
4633 {
4634 px2+=step;
4635 redraw=true;
4636 }
4637
4638 if(key[KEY_RIGHT])
4639 {
4640 px2-=step;
4641 redraw=true;
4642 }
4643
4644 if (bool mouse_down_now = (gui_mouse_b() & 1); mouse_down_now != mouse_down)
4645 {
4646 mouse_down = mouse_down_now;
4647 if (mouse_down)
4648 {
4649 mouse_x = gui_mouse_x();
4650 mouse_y = gui_mouse_y();
4651 mouse_off_x = px2;
4652 mouse_off_y = py2;
4653 }
4654 }
4655
4656 if (mouse_down)
4657 {
4658 if (abs(old_scale - scale) > 0.01)
4659 {
4660 mouse_x = gui_mouse_x();
4661 mouse_y = gui_mouse_y();
4662 mouse_off_x = px2;
4663 mouse_off_y = py2;
4664 old_scale = scale;
4665 }
4666 px2 = mouse_off_x + (gui_mouse_x() - mouse_x);
4667 py2 = mouse_off_y + (gui_mouse_y() - mouse_y);
4668 }
4669
4670 if (mouse_z)
4671 {
4672 double new_scale = scale;
4673 for (int q = 0; q < mouse_z; ++q)
4674 new_scale /= scale_step;
4675 for (int q = 0; q > mouse_z; --q)
4676 new_scale *= scale_step;
4677 position_mouse_z(0);
4678
4679 auto mx = (gui_mouse_x() - px2) / scale;
4680 auto my = (gui_mouse_y() - py2) / scale;
4681 scale = vbound(new_scale, MAX_SCALE, MIN_SCALE);
4682
4683 px2 = gui_mouse_x() - (mx * scale);
4684 py2 = gui_mouse_y() - (my * scale);
4685 }
4686
4687 if(keypressed() && !redraw)
4688 switch(readkey()>>8)
4689 {
4690 case KEY_PGUP:
4691 scale *= scale_step;
4692
4693 if(scale<MIN_SCALE) scale = MIN_SCALE;
4694
4695 redraw=true;
4696 break;
4697
4698 case KEY_PGDN:
4699 scale /= scale_step;
4700
4701 if(scale>MAX_SCALE) scale = MAX_SCALE;
4702
4703 redraw = true;
4704 break;
4705
4706 case KEY_HOME:
4707 scale /= scale_bigstep;
4708
4709 if(scale<MIN_SCALE) scale = MIN_SCALE;
4710
4711 redraw = true;
4712 break;
4713
4714 case KEY_END:
4715 scale *= scale_bigstep;
4716
4717 if(scale>MAX_SCALE) scale = MAX_SCALE;
4718
4719 redraw = true;
4720 break;
4721
4722 case KEY_TILDE:
4723 scale = 0.5;
4724 redraw = true;
4725 break;
4726
4727 case KEY_Z:
4728 px2 = w-zq_screen_w;
4729 py2 = h-zq_screen_h;
4730 vp_center = false;
4731 redraw = true;
4732 break;
4733
4734 case KEY_1:
4735 scale = 1.0;
4736 redraw = true;
4737 break;
4738
4739 case KEY_2:
4740 scale = 2.0;
4741 redraw = true;
4742 break;
4743
4744 case KEY_3:
4745 scale = 3.0;
4746 redraw = true;
4747 break;
4748
4749 case KEY_4:
4750 scale = 4.0;
4751 redraw = true;
4752 break;
4753
4754 case KEY_5:
4755 scale = 5.0;
4756 redraw = true;
4757 break;
4758
4759 case KEY_C:
4760 px2 = py2 = 0;
4761 redraw = vp_center = true;
4762 break;
4763
4764 case KEY_S:
4765 vp_showsize = !vp_showsize;
4766 redraw = true;
4767 break;
4768
4769 case KEY_D:
4770 vp_showpal = !vp_showpal;
4771 redraw = true;
4772 break;
4773
4774 case KEY_P:
4775 if(isviewingmap) break;
4776
4777 case KEY_ESC:
4778 done = true;
4779 break;
4780
4781 case KEY_SPACE:
4782 mapview_close();
4783 // TODO: why is `load_the_map` rendering a black dialog?
4784 if(isviewingmap ? load_the_map(skipmenu) : load_the_pic(pictoview,pal)==2)
4785 {
4786 done = true;
4787 }
4788 else
4789 {
4790 redraw = true;
4791 gui_bg_color = pblack;
4792 gui_fg_color = pwhite;
4793 scale = 1.0;
4794 zc_set_palette(pal);
4795 }
4796
4797 get_bw(pal,pblack,pwhite);
4798 break;
4799 }
4800 }
4801 while(!done);
4802
4803 destroy_bitmap(buf);
4804 zc_set_palette(RAMpal);
4805 gui_fg_color = oldfgcolor;
4806 gui_bg_color = oldbgcolor;
4807
4808 popup_zqdialog_end();
4809 position_mouse_z(0);
4810 viewer_overlay_rti.remove();
4811 set_center_root_rti(true);
4812 mapview_close();
4813 return D_O_K;
4814 }
4815
4816 static DIALOG loadmap_dlg[] =
4817 {
4818 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
4819 { jwin_win_proc, 0, 0, 225, 143, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "View Map", NULL, NULL },
4820 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4821 { jwin_text_proc, 32, 26, 96, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Resolution", NULL, NULL },
4822 // 3
4823 { jwin_radio_proc, 16, 36, 97, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "1/4 - 1024x352", NULL, NULL },
4824 { jwin_radio_proc, 16, 46, 97, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "1/2 - 2048x704", NULL, NULL },
4825 { jwin_radio_proc, 16, 56, 97, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "Full - 4096x1408", NULL, NULL },
4826 { jwin_text_proc, 144, 26, 97, 9, vc(11), vc(1), 0, 0, 0, 0, (void *) "Options", NULL, NULL },
4827 // 7
4828 { jwin_check_proc, 144, 36, 97, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Solidity", NULL, NULL },
4829 { jwin_check_proc, 144, 46, 97, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Flags", NULL, NULL },
4830 { jwin_check_proc, 144, 56, 97, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Dark", NULL, NULL },
4831 { jwin_check_proc, 144, 66, 97, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Items", NULL, NULL },
4832 // 11
4833 { jwin_button_proc, 42, 110, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
4834 { jwin_button_proc, 122, 110, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
4835 { jwin_check_proc, 16, 88, 97, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Save to Image", NULL, NULL },
4836 // 14
4837 { jwin_radio_proc, 16, 66, 97, 9, vc(14), vc(1), 0, 0, 0, 0, (void*)"2x - 8192x2816", NULL, NULL },
4838 { jwin_radio_proc, 16, 76, 97, 9, vc(14), vc(1), 0, 0, 0, 0, (void*)"4x - 16384x5632", NULL, NULL },
4839 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
4840 };
4841
4842 int32_t load_the_map(bool skipmenu)
4843 {
4844 static int32_t res = 0;
4845 static int32_t flags = cDEBUG;
4846
4847 loadmap_dlg[0].dp2 = get_zc_font(font_lfont);
4848 loadmap_dlg[3].flags = (res==2) ? D_SELECTED : 0;
4849 loadmap_dlg[4].flags = (res==1) ? D_SELECTED : 0;
4850 loadmap_dlg[5].flags = (res==0) ? D_SELECTED : 0;
4851 loadmap_dlg[7].flags = (flags&cWALK) ? D_SELECTED : 0;
4852 loadmap_dlg[8].flags = (flags&cFLAGS) ? D_SELECTED : 0;
4853 loadmap_dlg[9].flags = (flags&cNODARK) ? 0 : D_SELECTED;
4854 loadmap_dlg[10].flags = (flags&cNOITEM) ? 0 : D_SELECTED;
4855 loadmap_dlg[13].flags = 0;
4856 loadmap_dlg[14].flags = (res==3) ? D_SELECTED : 0;
4857 loadmap_dlg[15].flags = (res==4) ? D_SELECTED : 0;
4858
4859 if(!skipmenu)
4860 {
4861 large_dialog(loadmap_dlg);
4862
4863 if (do_zqdialog(loadmap_dlg, 11) != 11)
4864 {
4865 return 1;
4866 }
4867
4868 flags = cDEBUG;
4869
4870 if(loadmap_dlg[3].flags&D_SELECTED) res=2;
4871
4872 if(loadmap_dlg[4].flags&D_SELECTED) res=1;
4873
4874 if(loadmap_dlg[5].flags&D_SELECTED) res=0;
4875
4876 if(loadmap_dlg[7].flags&D_SELECTED) flags|=cWALK;
4877
4878 if(loadmap_dlg[8].flags&D_SELECTED) flags|=cFLAGS;
4879
4880 if(!(loadmap_dlg[9].flags&D_SELECTED)) flags|=cNODARK;
4881
4882 if(!(loadmap_dlg[10].flags&D_SELECTED)) flags|=cNOITEM;
4883
4884 if(loadmap_dlg[14].flags&D_SELECTED) res=3;
4885
4886 if(loadmap_dlg[15].flags&D_SELECTED) res=4;
4887 }
4888
4889 int32_t bw = (256*16)>>res;
4890 int32_t bh = (176*8)>>res;
4891 int32_t sw = 256>>res;
4892 int32_t sh = 176>>res;
4893 if(res>2)
4894 {
4895 bw = (256*16)<<(res-2);
4896 bh = (176*8)<<(res-2);
4897 sw = 256<<(res-2);
4898 sh = 176<<(res-2);
4899 }
4900
4901 mapview_open(flags, sw, sh, bw, bh);
4902
4903 vp_showpal = false;
4904 get_bw(picpal,pblack,pwhite);
4905 mapx = mapy = 0;
4906 mapscale = 1;
4907 imagepath[0] = 0;
4908
4909 if(loadmap_dlg[13].flags & D_SELECTED) saveMapAsImage(mapview_get_rti()->bitmap);
4910
4911 memcpy(mappal,RAMpal,sizeof(RAMpal));
4912
4913 return 0;
4914 }
4915
4916 int32_t onViewMap()
4917 {
4918 return onViewMapEx(false);
4919 }
4920 int32_t onViewMapEx(bool skipmenu)
4921 {
4922 int32_t temp_aligns=ShowMisalignments;
4923 ShowMisalignments=0;
4924 launchPicViewer(&bmap,mappal,mapx, mapy, mapscale,true,skipmenu);
4925 ShowMisalignments=temp_aligns;
4926 return D_O_K;
4927 }
4928
4929 static const char *mazedirstr[4] = {"North","South","West","East"};
4930 char _pathstr[40]="North,North,North,North";
4931
4932 char *pathstr(byte path[])
4933 {
4934 sprintf(_pathstr,"%s,%s,%s,%s",mazedirstr[path[0]],mazedirstr[path[1]],
4935 mazedirstr[path[2]],mazedirstr[path[3]]);
4936 return _pathstr;
4937 }
4938
4939 char _ticksstr[32]="99.99 seconds";
4940
4941 char *ticksstr(int32_t tics)
4942 {
4943 int32_t mins=tics/(60*60);
4944 tics=tics-(mins*60*60);
4945 int32_t secs=tics/60;
4946 tics=tics-(secs*60);
4947 tics=tics*100/60;
4948
4949 if(mins>0)
4950 {
4951 sprintf(_ticksstr,"%d:%02d.%02d",mins, secs, tics);
4952 }
4953 else
4954 {
4955 sprintf(_ticksstr,"%d.%02d seconds",secs, tics);
4956 }
4957
4958 return _ticksstr;
4959 }
4960
4961 ZC_FORMAT_PRINTF(7, 8)
4962 void textprintf_disabled(BITMAP *bmp, AL_CONST FONT *f, int32_t x, int32_t y, int32_t color_hl, int32_t color_sh, AL_CONST char *format, ...)
4963 {
4964 char buf[512];
4965 va_list ap;
4966 ASSERT(bmp);
4967 ASSERT(f);
4968 ASSERT(format);
4969
4970 va_start(ap, format);
4971 vsnprintf(buf, sizeof(buf), format, ap);
4972 va_end(ap);
4973
4974
4975 textout_ex(bmp, f, buf, x+1, y+1, color_hl, -1);
4976
4977 textout_ex(bmp, f, buf, x, y, color_sh, -1);
4978 }
4979
4980 ZC_FORMAT_PRINTF(7, 8)
4981 void textprintf_centre_disabled(BITMAP *bmp, AL_CONST FONT *f, int32_t x, int32_t y, int32_t color_hl, int32_t color_sh, AL_CONST char *format, ...)
4982 {
4983 char buf[512];
4984 va_list ap;
4985 ASSERT(bmp);
4986 ASSERT(f);
4987 ASSERT(format);
4988
4989 va_start(ap, format);
4990 vsnprintf(buf, sizeof(buf), format, ap);
4991 va_end(ap);
4992
4993 textout_centre_ex(bmp, f, buf, x+1, y+1, color_hl, -1);
4994 textout_centre_ex(bmp, f, buf, x, y, color_sh, -1);
4995 }
4996
4997 void draw_sqr_frame(size_and_pos const& sqr)
4998 {
4999 jwin_draw_frame(screen,sqr.x,sqr.y,sqr.tw(),sqr.th(),FR_DEEP);
5000 }
5001 void draw_sqr_icon(size_and_pos const& sqr, BITMAP* icon)
5002 {
5003 stretch_blit(icon, screen, 0, 0, 16, 16, sqr.x+2, sqr.y+2, sqr.tw()-4, sqr.th()-4);
5004 }
5005 void draw_sqr_nums(size_and_pos const& sqr, FONT* f, bool center, int num)
5006 {
5007 if(center)
5008 textprintf_centre_ex(screen,f,sqr.x+txtoffs_single.x,sqr.y+txtoffs_single.y,jwin_pal[jcBOXFG],-1,"%d",num);
5009 else
5010 textprintf_ex(screen,f,sqr.x+txtoffs_single.x,sqr.y+txtoffs_single.y,jwin_pal[jcBOXFG],-1,"%d",num);
5011 }
5012 void draw_sqr_nums(size_and_pos const& sqr, FONT* f, bool center, int num1, int num2)
5013 {
5014 if(center)
5015 {
5016 textprintf_centre_ex(screen,f,sqr.x+txtoffs_double_1.x,sqr.y+txtoffs_double_1.y,jwin_pal[jcBOXFG],-1,"%d",num1);
5017 textprintf_centre_ex(screen,f,sqr.x+txtoffs_double_2.x,sqr.y+txtoffs_double_2.y,jwin_pal[jcBOXFG],-1,"%d",num2);
5018 }
5019 else
5020 {
5021 textprintf_ex(screen,f,sqr.x+txtoffs_double_1.x,sqr.y+txtoffs_double_1.y,jwin_pal[jcBOXFG],-1,"%d",num1);
5022 textprintf_ex(screen,f,sqr.x+txtoffs_double_2.x,sqr.y+txtoffs_double_2.y,jwin_pal[jcBOXFG],-1,"%d",num2);
5023 }
5024 }
5025 void draw_sqr_btn(size_and_pos const& sqr, const char* txt, int flags, FONT* f = nullptr)
5026 {
5027 if(sqr.x < 0) return;
5028 FONT* tfont = font;
5029 if(f)
5030 font = f;
5031 draw_text_button(screen, sqr.x, sqr.y, sqr.tw(), sqr.th(), txt, 0, 0, flags, true);
5032 font = tfont;
5033 }
5034 void draw_sqr_btn(size_and_pos const& sqr, int icon, int flags, FONT* f = nullptr)
5035 {
5036 if(sqr.x < 0) return;
5037 FONT* tfont = font;
5038 if(f)
5039 font = f;
5040 draw_icon_button(screen, sqr.x, sqr.y, sqr.tw(), sqr.th(), icon, 0, 0, flags, true);
5041 font = tfont;
5042 }
5043
5044 void drawpanel()
5045 {
5046 mapscr *scr=Map.CurrScr();
5047 int32_t NextCombo = combobuf[Combo].nextcombo;
5048 int32_t NextCSet = combobuf[Combo].nextcset;
5049 if(combobuf[Combo].animflags & AF_CYCLEUNDERCOMBO)
5050 {
5051 NextCombo = scr->undercombo;
5052 NextCSet = scr->undercset;
5053 }
5054 if(combobuf[Combo].animflags & AF_CYCLENOCSET)
5055 NextCSet = CSet;
5056
5057 FONT* tfont = font;
5058 if(prv_mode)
5059 {
5060 jwin_draw_frame(screen,0,preview_panel.y,preview_panel.x+preview_panel.w, preview_panel.h, FR_WIN);
5061 rectfill(screen,preview_panel.x,preview_panel.y+2,preview_panel.x+preview_panel.w-3,preview_panel.y+preview_panel.h-3,jwin_pal[jcBOX]);
5062 }
5063 else
5064 {
5065 auto& sqr = main_panel;
5066 rectfill(screen,sqr.x,sqr.y,sqr.x+sqr.w-1,sqr.y+sqr.h-1, jwin_pal[jcBOX]);
5067 refresh(rSCRMAP);
5068 jwin_draw_frame(screen,sqr.x,sqr.y,sqr.w,sqr.h, FR_WIN);
5069
5070 font = get_custom_font(CFONT_GUI);
5071 draw_sqr_btn(squarepanel_swap_btn, "SWP", 0);
5072 if(compact_square_panels)
5073 {
5074 textprintf_centre_ex(screen,font,squarepanel_up_btn.cx(),squarepanel_up_btn.y-text_height(font)-2,jwin_pal[jcBOXFG],-1,"%d",compact_active_panel);
5075 draw_sqr_btn(squarepanel_up_btn, BTNICON_ARROW_UP, 0);
5076 draw_sqr_btn(squarepanel_down_btn, BTNICON_ARROW_DOWN, 0);
5077 }
5078 font = tfont;
5079
5080 FONT* sqr_text_font = (is_compact && compact_square_panels) ? get_custom_font(CFONT_GUI) : font;
5081 //Item:
5082 if(itemsqr_pos.x > -1)
5083 {
5084 draw_sqr_frame(itemsqr_pos);
5085 if(scr->hasitem)
5086 {
5087 rectfill(screen,itemsqr_pos.x+2,itemsqr_pos.y+2,itemsqr_pos.x+itemsqr_pos.tw()-3,itemsqr_pos.y+itemsqr_pos.th()-3,0);
5088 overtile16_scale(screen, itemsbuf[scr->item].tile,itemsqr_pos.x+2,itemsqr_pos.y+2,itemsbuf[scr->item].csets&15,0,itemsqr_pos.tw()-4,itemsqr_pos.th()-4);
5089 }
5090 else draw_sqr_icon(itemsqr_pos, icon_bmp[0][coord_frame]);
5091 draw_sqr_nums(itemsqr_pos, sqr_text_font, panel_align == 1, scr->itemx, scr->itemy);
5092 }
5093 //Flag:
5094 if(flagsqr_pos.x > -1)
5095 {
5096 draw_sqr_frame(flagsqr_pos);
5097 draw_sqr_icon(flagsqr_pos,flag_bmp[Flag%16][coord_frame]);
5098 draw_sqr_nums(flagsqr_pos, sqr_text_font, panel_align == 1, Flag);
5099 }
5100
5101 //Stairs:
5102 if(stairsqr_pos.x > -1)
5103 {
5104 draw_sqr_frame(stairsqr_pos);
5105 draw_sqr_icon(stairsqr_pos,icon_bmp[1][coord_frame]);
5106 draw_sqr_nums(stairsqr_pos, sqr_text_font, panel_align == 1, scr->stairx, scr->stairy);
5107 }
5108
5109 //Green arrival square:
5110 bool disabled_arrival = get_qr(qr_NOARRIVALPOINT);
5111 if(warparrival_pos.x > -1)
5112 {
5113 draw_sqr_frame(warparrival_pos);
5114 BITMAP* icon = icon_bmp[2][coord_frame];
5115 if(disabled_arrival)
5116 {
5117 icon = create_bitmap_ex(8,16,16);
5118 blit(icon_bmp[2][0], icon, 0, 0, 0, 0, 16, 16);
5119 replColor(icon, 0xE7, 0xEA, 0xEA, false);
5120 replColor(icon, 0xE8, 0xE2, 0xE2, false);
5121 }
5122
5123 draw_sqr_icon(warparrival_pos, icon);
5124 draw_sqr_nums(warparrival_pos, sqr_text_font, panel_align == 1, scr->warparrivalx, scr->warparrivaly);
5125
5126 if(disabled_arrival)
5127 destroy_bitmap(icon);
5128 }
5129
5130 //Blue return squares:
5131 for(int32_t i=0; i<4; i++)
5132 {
5133 if(warpret_pos[i].x < 0) continue;
5134 draw_sqr_frame(warpret_pos[i]);
5135 draw_sqr_icon(warpret_pos[i], icon_bmp[ICON_BMP_RETURN_A+i][coord_frame]);
5136 draw_sqr_nums(warpret_pos[i], sqr_text_font, panel_align == 1, scr->warpreturnx[i], scr->warpreturny[i]);
5137 }
5138
5139 // Enemies
5140 auto& ep = enemy_prev_pos;
5141 if(ep.x > -1)
5142 {
5143 if(ep.fw > -1)
5144 {
5145 rectfill(screen, ep.x, ep.y, ep.x+ep.tw()-1,ep.y+ep.th()-1,vc(0));
5146 rectfill(screen, ep.x+ep.fw, ep.y+ep.fh, ep.x+ep.tw()-1, ep.y+ep.th()-1, jwin_pal[jcBOX]);
5147 jwin_draw_frag_frame(screen, ep.x, ep.y, ep.tw(), ep.th(), ep.fw, ep.fh, FR_DEEP);
5148 }
5149 else
5150 {
5151 rectfill(screen, ep.x, ep.y, ep.x+ep.tw()-1,ep.y+ep.th()-1,vc(0));
5152 draw_sqr_frame(ep);
5153 }
5154 for(int32_t i=0; i< 10 && Map.CurrScr()->enemy[i]!=0; i++)
5155 {
5156 int32_t id = Map.CurrScr()->enemy[i];
5157 int32_t tile = get_qr(qr_NEWENEMYTILES) ? guysbuf[id].e_tile : guysbuf[id].tile;
5158 int32_t cset = guysbuf[id].cset;
5159 auto& sqr = ep.subsquare(i);
5160 if(tile)
5161 overtile16_scale(screen, tile+efrontfacingtile(id),sqr.x,sqr.y,cset,0,sqr.tw(),sqr.th());
5162 }
5163 }
5164 }
5165 font = tfont;
5166 }
5167
5168 void show_screen_error(const char *str, int32_t i, int32_t c)
5169 {
5170 rectfill(screen, screrrorpos.x-text_length(get_zc_font(font_lfont_l),str),screrrorpos.y-(i*16),screrrorpos.x,screrrorpos.y-((i-1)*16)-4,vc(0));
5171 textout_shadowed_ex(screen,get_zc_font(font_lfont_l), str,screrrorpos.x-text_length(get_zc_font(font_lfont_l),str),screrrorpos.y-(i*16),c,vc(0),-1);
5172 }
5173
5174 void tile_warp_notification(int32_t which, char *buf)
5175 {
5176 char letter = 'A'+which;
5177
5178 switch(Map.CurrScr()->tilewarptype[which])
5179 {
5180 case wtCAVE:
5181 sprintf(buf,"Tile Warp %c: Cave/Item Cellar",letter);
5182 break;
5183
5184 default:
5185 {
5186 char buf2[30];
5187
5188 if(strlen(DMaps[Map.CurrScr()->tilewarpdmap[which]].name)==0)
5189 {
5190 sprintf(buf2,"%d",Map.CurrScr()->tilewarpdmap[which]);
5191 }
5192 else
5193 sprintf(buf2,"%d-%s",Map.CurrScr()->tilewarpdmap[which],DMaps[Map.CurrScr()->tilewarpdmap[which]].name);
5194
5195 sprintf(buf,"Tile Warp %c: %s, %02X", letter, buf2, Map.CurrScr()->tilewarpscr[which]);
5196 break;
5197 }
5198
5199 case wtNOWARP:
5200 sprintf(buf,"Tile Warp %c: Cancel Warp", letter);
5201 break;
5202 }
5203 }
5204
5205 void side_warp_notification(int32_t which, int32_t dir, char *buf)
5206 {
5207 char letter = 'A'+which;
5208 char buf3[16];
5209
5210 if(dir==0 && Map.CurrScr()->timedwarptics)
5211 sprintf(buf3,"%s, Timed",mazedirstr[dir]);
5212 else if(dir==4)
5213 sprintf(buf3,"Timed");
5214 else
5215 strcpy(buf3, mazedirstr[dir]);
5216
5217 switch(Map.CurrScr()->sidewarptype[which])
5218 {
5219 case wtCAVE:
5220 sprintf(buf,"Side Warp %c (%s): Cave/Item Cellar",letter, buf3);
5221 break;
5222
5223 default:
5224 {
5225 // Destination DMap name
5226 if(strlen(DMaps[Map.CurrScr()->sidewarpdmap[which]].name)==0)
5227 {
5228 sprintf(buf,"Side Warp %c (%s): %d, %02X", letter, buf3, Map.CurrScr()->sidewarpdmap[which], Map.CurrScr()->sidewarpscr[which]);
5229 }
5230 else
5231 sprintf(buf,"Side Warp %c (%s): %d-%s, %02X", letter, buf3, Map.CurrScr()->sidewarpdmap[which],DMaps[Map.CurrScr()->sidewarpdmap[which]].name, Map.CurrScr()->sidewarpscr[which]);
5232
5233 break;
5234 }
5235
5236 case wtNOWARP:
5237 sprintf(buf,"Side Warp %c (%s): Cancel Warp", letter, buf3);
5238 break;
5239 }
5240 }
5241
5242 static bool arrowcursor = true; // Used by combo aliases and Combo Brush cursors. -L
5243
5244 void xout(BITMAP* dest, int x, int y, int x2, int y2, int c, int bgc = -1)
5245 {
5246 //BG Fill
5247 if(bgc > -1)
5248 rectfill(dest, x, y, x2, y2, bgc);
5249 ++x; ++y; --x2; --y2;
5250 //Border
5251 safe_rect(dest, x, y, x2, y2, c);
5252 //line(dest, x, y, x2, y, c);
5253 //line(dest, x, y, x, y2, c);
5254 //X
5255 line(dest, x, y, x2, y2, c);
5256 line(dest, x, y2, x2, y, c);
5257 }
5258
5259 void put_autocombo_engravings(BITMAP* dest, combo_auto const& ca, bool selected, int32_t x, int32_t y, int32_t scale)
5260 {
5261 if (!ca.valid())
5262 {
5263 if (ca.getDisplay() > 0)
5264 put_engraving(dest, x, y, 15, scale);
5265 }
5266 else
5267 {
5268 if (ca.getType() == AUTOCOMBO_Z4 || ca.getType() == AUTOCOMBO_DOR)
5269 {
5270 byte hei = vbound(ca.getArg() + 1, 1, 9);
5271 if (selected)
5272 hei = vbound(cauto_height, 1, 9);
5273 put_engraving(dest, x, y, 15 - hei, scale);
5274 }
5275 }
5276 }
5277
5278 static void draw_screenunit_map_screen2(VisibleScreen visible_screen)
5279 {
5280 BITMAP* screen_bitmap = screen;
5281
5282 int num_screens_to_draw = Map.getViewSize();
5283 int screen = visible_screen.screen;
5284 int xoff = visible_screen.xoff;
5285 int yoff = visible_screen.yoff;
5286
5287 mapscr* scr = visible_screen.scr;
5288 if (!layers_valid(scr))
5289 fix_layers(scr, true);
5290
5291 clear_to_color(mapscreenbmp, 0);
5292
5293 int view_scr_x = Map.getViewScr() % 16;
5294 int view_scr_y = Map.getViewScr() / 16;
5295 int scr_x = screen % 16;
5296 int scr_y = screen / 16;
5297 int edge_xoff = 0, edge_yoff = 0;
5298 if(showedges)
5299 {
5300 if (scr_x == view_scr_x)
5301 edge_xoff = 16;
5302 else
5303 xoff -= 16;
5304
5305 if (scr_y == view_scr_y)
5306 edge_yoff = 16;
5307 else
5308 yoff -= 16;
5309 }
5310
5311 // TODO: should be better to move this out of draw_screenunit_map_screen.
5312 if (showedges && screen < 128)
5313 {
5314 bool peek_above = scr_y == view_scr_y;
5315 bool peek_below = scr_y == view_scr_y + num_screens_to_draw - 1;
5316 bool peek_left = scr_x == view_scr_x;
5317 bool peek_right = scr_x == view_scr_x + num_screens_to_draw - 1;
5318
5319 int right_col = 272 - (num_screens_to_draw > 1 ? 16 : 0);
5320 int bottom_row = 192 - (num_screens_to_draw > 1 ? 16 : 0);
5321
5322 //not the first row of screens
5323 if (peek_above)
5324 {
5325 if(screen>15 && !NoScreenPreview)
5326 {
5327 Map.drawrow(mapscreenbmp, edge_xoff, 0, Flags, 160, -1, screen-16);
5328 }
5329 else
5330 {
5331 Map.drawstaticrow(mapscreenbmp, edge_xoff, 0);
5332 }
5333 }
5334
5335 //not the last row of screens
5336 if (peek_below)
5337 {
5338 if(screen + 16 < 0x80 && !NoScreenPreview)
5339 {
5340 Map.drawrow(mapscreenbmp, edge_xoff, bottom_row, Flags, 0, -1, screen+16);
5341 }
5342 else
5343 {
5344 Map.drawstaticrow(mapscreenbmp, edge_xoff, bottom_row);
5345 }
5346 }
5347
5348 //not the first column of screens
5349 if (peek_left)
5350 {
5351 if(screen&0x0F && !NoScreenPreview)
5352 {
5353 Map.drawcolumn(mapscreenbmp, 0, edge_yoff, Flags, 15, -1, screen-1);
5354 }
5355 else
5356 {
5357 Map.drawstaticcolumn(mapscreenbmp, 0, edge_yoff);
5358 }
5359 }
5360
5361 //not the last column of screens
5362 if (peek_right)
5363 {
5364 if((screen&0x0F)<15 && !NoScreenPreview)
5365 {
5366 Map.drawcolumn(mapscreenbmp, right_col, edge_yoff, Flags, 0, -1, screen+1);
5367 }
5368 else
5369 {
5370 Map.drawstaticcolumn(mapscreenbmp, right_col, edge_yoff);
5371 }
5372 }
5373
5374 //not the first row or first column of screens
5375 if (peek_above && peek_left)
5376 {
5377 if((screen>15)&&(screen&0x0F) && !NoScreenPreview)
5378 {
5379 Map.drawblock(mapscreenbmp, 0, 0, Flags, 175, -1, screen-17);
5380 }
5381 else
5382 {
5383 Map.drawstaticblock(mapscreenbmp, 0, 0);
5384 }
5385 }
5386
5387 //not the first row or last column of screens
5388 if (peek_above && peek_right)
5389 {
5390 if((screen>15)&&((screen&0x0F)<15) && !NoScreenPreview)
5391 {
5392 Map.drawblock(mapscreenbmp, right_col, 0, Flags, 160, -1, screen-15);
5393 }
5394 else
5395 {
5396 Map.drawstaticblock(mapscreenbmp, right_col, 0);
5397 }
5398 }
5399
5400 //not the last row or first column of screens
5401 if (peek_below && peek_left)
5402 {
5403 if((screen<112)&&(screen&0x0F) && !NoScreenPreview)
5404 {
5405 Map.drawblock(mapscreenbmp, 0, bottom_row, Flags, 15, -1, screen+15);
5406 }
5407 else
5408 {
5409 Map.drawstaticblock(mapscreenbmp, 0, bottom_row);
5410 }
5411 }
5412
5413 //not the last row or last column of screens
5414 if (peek_below && peek_right)
5415 {
5416 if((screen<112)&&((screen&0x0F)<15) && !NoScreenPreview)
5417 {
5418 Map.drawblock(mapscreenbmp, right_col, bottom_row, Flags, 0, -1, screen+17);
5419 }
5420 else
5421 {
5422 Map.drawstaticblock(mapscreenbmp, right_col, bottom_row);
5423 }
5424 }
5425 }
5426
5427 if (ShowSquares && Map.getViewSize() < 4)
5428 {
5429 if(scr->stairx || scr->stairy)
5430 {
5431 int32_t x1 = scr->stairx+edge_xoff;
5432 int32_t y1 = scr->stairy+edge_yoff;
5433 safe_rect(mapscreenbmp,x1,y1,x1+15,y1+15,vc(14));
5434 }
5435
5436 if(scr->warparrivalx || scr->warparrivaly)
5437 {
5438 int32_t x1 = scr->warparrivalx +edge_xoff;
5439 int32_t y1 = scr->warparrivaly +edge_yoff;
5440 safe_rect(mapscreenbmp,x1,y1,x1+15,y1+15,vc(10));
5441 }
5442
5443 for(int32_t i=0; i<4; i++) if(scr->warpreturnx[i] || scr->warpreturny[i])
5444 {
5445 int32_t x1 = scr->warpreturnx[i]+edge_xoff;
5446 int32_t y1 = scr->warpreturny[i]+edge_yoff;
5447 int32_t clr = vc(9);
5448
5449 if(FlashWarpSquare==i)
5450 {
5451 if(!FlashWarpClk)
5452 FlashWarpSquare=-1;
5453 else if(!(--FlashWarpClk%3))
5454 clr = vc(15);
5455 }
5456
5457 safe_rect(mapscreenbmp,x1,y1,x1+15,y1+15,clr);
5458 }
5459 }
5460
5461 if(ShowFFCs)
5462 {
5463 mapscr* ffscr = prv_mode ? Map.get_prvscr() : scr;
5464 int num_ffcs = ffscr->numFFC();
5465 for(int32_t i=num_ffcs-1; i>=0; i--)
5466 {
5467 ffcdata& ff = ffscr->ffcs[i];
5468 if(ff.data !=0 && (ff.layer >= CurrentLayer || (ff.flags&ffc_overlay)))
5469 {
5470 auto x = ff.x+edge_xoff;
5471 auto y = ff.y+edge_yoff;
5472 safe_rect(mapscreenbmp, x+0, y+0, x+ff.txsz*16-1, y+ff.tysz*16-1, vc(12));
5473 }
5474 }
5475 }
5476
5477 if(num_screens_to_draw == 1 && !(Flags&cDEBUG) && pixeldb==1)
5478 {
5479 for(int32_t j=168; j<176; j++)
5480 {
5481 for(int32_t i=0; i<256; i++)
5482 {
5483 if(((i^j)&1)==0)
5484 {
5485 putpixel(mapscreenbmp,edge_xoff+i,
5486 edge_yoff+j,vc(blackout_color));
5487 }
5488 }
5489 }
5490 }
5491
5492 int w = mapscreenbmp->w * mapscreen_single_scale;
5493 int h = mapscreenbmp->h * mapscreen_single_scale;
5494 stretch_blit(mapscreenbmp, screen_bitmap, 0, 0, mapscreenbmp->w, mapscreenbmp->h, mapscreen_x + xoff, mapscreen_y + yoff, w, h);
5495 }
5496
5497 static void draw_screenunit_map_screen(VisibleScreen visible_screen)
5498 {
5499 BITMAP* screen_bitmap = screen;
5500
5501 if (HighQualityScreenRendering) return draw_screenunit_map_screen2(visible_screen);
5502
5503 int num_screens_to_draw = Map.getViewSize();
5504 int screen = visible_screen.screen;
5505 int xoff = visible_screen.xoff;
5506 int yoff = visible_screen.yoff;
5507
5508 mapscr* scr = visible_screen.scr;
5509 if (!layers_valid(scr))
5510 fix_layers(scr, true);
5511
5512 clear_to_color(mapscreenbmp, jwin_pal[jcBOX]);
5513 if (LayerDitherBG > -1)
5514 {
5515 if (LayerDitherSz > 0)
5516 ditherblit(mapscreenbmp, nullptr, vc(LayerDitherBG), dithChecker, LayerDitherSz);
5517 else
5518 clear_to_color(mapscreenbmp, vc(LayerDitherBG));
5519 }
5520
5521 int view_scr_x = Map.getViewScr() % 16;
5522 int view_scr_y = Map.getViewScr() / 16;
5523 int scr_x = screen % 16;
5524 int scr_y = screen / 16;
5525 int edge_xoff = 0, edge_yoff = 0;
5526 if(showedges)
5527 {
5528 if (scr_x == view_scr_x)
5529 edge_xoff = 16;
5530 else
5531 xoff -= 16;
5532
5533 if (scr_y == view_scr_y)
5534 edge_yoff = 16;
5535 else
5536 yoff -= 16;
5537 }
5538
5539 combotile_add_x = mapscreen_x + xoff;
5540 combotile_add_y = mapscreen_y + yoff;
5541 combotile_mul_x = mapscreen_single_scale;
5542 combotile_mul_y = mapscreen_single_scale;
5543 Map.draw(mapscreenbmp, scr_x == view_scr_x && showedges ? 16 : 0, scr_y == view_scr_y && showedges ? 16 : 0, Flags, Map.getCurrMap(), screen, ActiveLayerHighlight ? CurrentLayer : -1);
5544 combotile_add_x = 0;
5545 combotile_add_y = 0;
5546 combotile_mul_x = 1;
5547 combotile_mul_y = 1;
5548
5549 // TODO: should be better to move this out of draw_screenunit_map_screen.
5550 if (showedges && screen < 128)
5551 {
5552 bool peek_above = scr_y == view_scr_y;
5553 bool peek_below = scr_y == view_scr_y + num_screens_to_draw - 1;
5554 bool peek_left = scr_x == view_scr_x;
5555 bool peek_right = scr_x == view_scr_x + num_screens_to_draw - 1;
5556
5557 int right_col = 272 - (num_screens_to_draw > 1 ? 16 : 0);
5558 int bottom_row = 192 - (num_screens_to_draw > 1 ? 16 : 0);
5559
5560 //not the first row of screens
5561 if (peek_above)
5562 {
5563 if(screen>15 && !NoScreenPreview)
5564 {
5565 Map.drawrow(mapscreenbmp, edge_xoff, 0, Flags, 160, -1, screen-16);
5566 }
5567 else
5568 {
5569 Map.drawstaticrow(mapscreenbmp, edge_xoff, 0);
5570 }
5571 }
5572
5573 //not the last row of screens
5574 if (peek_below)
5575 {
5576 if(screen + 16 < 0x80 && !NoScreenPreview)
5577 {
5578 Map.drawrow(mapscreenbmp, edge_xoff, bottom_row, Flags, 0, -1, screen+16);
5579 }
5580 else
5581 {
5582 Map.drawstaticrow(mapscreenbmp, edge_xoff, bottom_row);
5583 }
5584 }
5585
5586 //not the first column of screens
5587 if (peek_left)
5588 {
5589 if(screen&0x0F && !NoScreenPreview)
5590 {
5591 Map.drawcolumn(mapscreenbmp, 0, edge_yoff, Flags, 15, -1, screen-1);
5592 }
5593 else
5594 {
5595 Map.drawstaticcolumn(mapscreenbmp, 0, edge_yoff);
5596 }
5597 }
5598
5599 //not the last column of screens
5600 if (peek_right)
5601 {
5602 if((screen&0x0F)<15 && !NoScreenPreview)
5603 {
5604 Map.drawcolumn(mapscreenbmp, right_col, edge_yoff, Flags, 0, -1, screen+1);
5605 }
5606 else
5607 {
5608 Map.drawstaticcolumn(mapscreenbmp, right_col, edge_yoff);
5609 }
5610 }
5611
5612 //not the first row or first column of screens
5613 if (peek_above && peek_left)
5614 {
5615 if((screen>15)&&(screen&0x0F) && !NoScreenPreview)
5616 {
5617 Map.drawblock(mapscreenbmp, 0, 0, Flags, 175, -1, screen-17);
5618 }
5619 else
5620 {
5621 Map.drawstaticblock(mapscreenbmp, 0, 0);
5622 }
5623 }
5624
5625 //not the first row or last column of screens
5626 if (peek_above && peek_right)
5627 {
5628 if((screen>15)&&((screen&0x0F)<15) && !NoScreenPreview)
5629 {
5630 Map.drawblock(mapscreenbmp, right_col, 0, Flags, 160, -1, screen-15);
5631 }
5632 else
5633 {
5634 Map.drawstaticblock(mapscreenbmp, right_col, 0);
5635 }
5636 }
5637
5638 //not the last row or first column of screens
5639 if (peek_below && peek_left)
5640 {
5641 if((screen<112)&&(screen&0x0F) && !NoScreenPreview)
5642 {
5643 Map.drawblock(mapscreenbmp, 0, bottom_row, Flags, 15, -1, screen+15);
5644 }
5645 else
5646 {
5647 Map.drawstaticblock(mapscreenbmp, 0, bottom_row);
5648 }
5649 }
5650
5651 //not the last row or last column of screens
5652 if (peek_below && peek_right)
5653 {
5654 if((screen<112)&&((screen&0x0F)<15) && !NoScreenPreview)
5655 {
5656 Map.drawblock(mapscreenbmp, right_col, bottom_row, Flags, 0, -1, screen+17);
5657 }
5658 else
5659 {
5660 Map.drawstaticblock(mapscreenbmp, right_col, bottom_row);
5661 }
5662 }
5663 }
5664
5665 if (ShowSquares && Map.getViewSize() < 4)
5666 {
5667 if(scr->stairx || scr->stairy)
5668 {
5669 int32_t x1 = scr->stairx+edge_xoff;
5670 int32_t y1 = scr->stairy+edge_yoff;
5671 safe_rect(mapscreenbmp,x1,y1,x1+15,y1+15,vc(14));
5672 }
5673
5674 if(scr->warparrivalx || scr->warparrivaly)
5675 {
5676 int32_t x1 = scr->warparrivalx +edge_xoff;
5677 int32_t y1 = scr->warparrivaly +edge_yoff;
5678 safe_rect(mapscreenbmp,x1,y1,x1+15,y1+15,vc(10));
5679 }
5680
5681 for(int32_t i=0; i<4; i++) if(scr->warpreturnx[i] || scr->warpreturny[i])
5682 {
5683 int32_t x1 = scr->warpreturnx[i]+edge_xoff;
5684 int32_t y1 = scr->warpreturny[i]+edge_yoff;
5685 int32_t clr = vc(9);
5686
5687 if(FlashWarpSquare==i)
5688 {
5689 if(!FlashWarpClk)
5690 FlashWarpSquare=-1;
5691 else if(!(--FlashWarpClk%3))
5692 clr = vc(15);
5693 }
5694
5695 safe_rect(mapscreenbmp,x1,y1,x1+15,y1+15,clr);
5696 }
5697 }
5698
5699 if(ShowFFCs)
5700 {
5701 mapscr* ffscr = prv_mode ? Map.get_prvscr() : scr;
5702 int num_ffcs = ffscr->numFFC();
5703 for(int32_t i=num_ffcs-1; i>=0; i--)
5704 {
5705 ffcdata& ff = ffscr->ffcs[i];
5706 if(ff.data !=0 && (ff.layer >= CurrentLayer || (!CurrentLayer && ff.layer < 0) || (ff.flags&ffc_overlay)))
5707 {
5708 auto x = ff.x+edge_xoff;
5709 auto y = ff.y+edge_yoff;
5710 safe_rect(mapscreenbmp, x+0, y+0, x+ff.txsz*16-1, y+ff.tysz*16-1, vc(12));
5711 }
5712 }
5713 }
5714
5715 if(num_screens_to_draw == 1 && !(Flags&cDEBUG) && pixeldb==1)
5716 {
5717 for(int32_t j=168; j<176; j++)
5718 {
5719 for(int32_t i=0; i<256; i++)
5720 {
5721 if(((i^j)&1)==0)
5722 {
5723 putpixel(mapscreenbmp,edge_xoff+i,
5724 edge_yoff+j,vc(blackout_color));
5725 }
5726 }
5727 }
5728 }
5729
5730 int w = mapscreenbmp->w * mapscreen_single_scale;
5731 int h = mapscreenbmp->h * mapscreen_single_scale;
5732 stretch_blit(mapscreenbmp, screen_bitmap, 0, 0, mapscreenbmp->w, mapscreenbmp->h, mapscreen_x + xoff, mapscreen_y + yoff, w, h);
5733 }
5734
5735 static void draw_static_pos(const size_and_pos& sqr)
5736 {
5737 draw_static(screen, sqr.x, sqr.y, sqr.w, sqr.h);
5738 }
5739
5740 void draw_screenunit(int32_t unit, int32_t flags)
5741 {
5742 FONT* tfont = font;
5743 switch(unit)
5744 {
5745 case rSCRMAP:
5746 {
5747 mmap_mark_active();
5748
5749 size_and_pos *mini_sqr = &minimap;
5750 size_and_pos *real_mini_sqr = &real_minimap;
5751
5752 if(zoomed_minimap)
5753 {
5754 mini_sqr = &minimap_zoomed;
5755 real_mini_sqr = &real_minimap_zoomed;
5756 }
5757
5758 auto txt_x = real_mini_sqr->x+2+8*real_mini_sqr->xscale;
5759 auto txt_y = real_mini_sqr->y+2+8*real_mini_sqr->yscale;
5760
5761 rectfill(screen, mini_sqr->x-1, mini_sqr->y-2,mini_sqr->x+mini_sqr->w-1,mini_sqr->y+mini_sqr->h-1,jwin_pal[jcBOX]);
5762 if(zoomed_minimap)
5763 jwin_draw_frame(screen, mini_sqr->x-1, mini_sqr->y-2,mini_sqr->w,mini_sqr->h,FR_WIN);
5764 jwin_draw_minimap_frame(screen,real_mini_sqr->x,real_mini_sqr->y,real_mini_sqr->tw(), real_mini_sqr->th(), real_mini_sqr->xscale, FR_DEEP);
5765
5766 if(Map.getCurrMap()<Map.getMapCount())
5767 {
5768 for(int32_t i=0; i<MAPSCRS; i++)
5769 {
5770 auto& sqr = real_mini_sqr->subsquare(i);
5771
5772 if(Map.Scr(i)->valid&mVALID)
5773 {
5774 // Drawing is handled by mmap_draw.
5775 }
5776 else
5777 {
5778 if (InvalidBG == 2)
5779 {
5780 draw_checkerboard(screen, sqr.x, sqr.y, sqr.w);
5781 }
5782 else if (InvalidBG == 1)
5783 {
5784 draw_static_pos(sqr);
5785 }
5786 else
5787 {
5788 int32_t offs = 2*(sqr.w/9);
5789 draw_x(screen, sqr.x+offs, sqr.y+offs, sqr.x+sqr.w-1-offs, sqr.y+sqr.h-1-offs, vc(15));
5790 }
5791 }
5792 }
5793
5794 int32_t s=Map.getCurrScr();
5795
5796 BITMAP* txtbmp = create_bitmap_ex(8,256,64);
5797 clear_bitmap(txtbmp);
5798 int txtscale = zoomed_minimap ? (is_compact ? 2 : 3) : 1;
5799 font = get_zc_font(font_lfont_l);
5800
5801 int32_t space = text_length(font, "255")+2, spc_s = text_length(font, "S")+2, spc_m = text_length(font, "M")+2;
5802 textprintf_disabled(txtbmp,font,0,0,jwin_pal[jcLIGHT],jwin_pal[jcMEDDARK],"M");
5803 static int map_shortcut_tooltip_id = ttip_register_id();
5804 ttip_install(map_shortcut_tooltip_id, "Prev map: ,\nNext map: .", txt_x, txt_y, 30, 20, txt_x, txt_y - 60);
5805
5806 textprintf_ex(txtbmp,font,spc_m,0,jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%-3d",Map.getCurrMap()+1);
5807
5808 textprintf_disabled(txtbmp,font,spc_m+space,0,jwin_pal[jcLIGHT],jwin_pal[jcMEDDARK],"S");
5809 textprintf_ex(txtbmp,font,spc_m+space+spc_s,0,jwin_pal[jcBOXFG],jwin_pal[jcBOX],"0x%02X (%d)",s, s);
5810 masked_stretch_blit(txtbmp, screen, 0, 0, 256, 64, txt_x, txt_y, 256*txtscale, 64*txtscale);
5811 destroy_bitmap(txtbmp);
5812 }
5813 }
5814 break;
5815 case rMAP:
5816 {
5817 refresh_visible_screens();
5818 mapscreen_single_scale = (double)mapscreen_screenunit_scale / Map.getViewSize();
5819
5820 int num_combos_width = 16 * Map.getViewSize();
5821 int num_combos_height = 11 * Map.getViewSize();
5822
5823 if(CurrentLayer > 0 && !mapscreen_valid_layers[CurrentLayer-1])
5824 CurrentLayer = 0;
5825
5826 if (HighQualityScreenRendering)
5827 {
5828 int startxint = mapscreen_x+(showedges?int(16*mapscreen_single_scale):0);
5829 int startyint = mapscreen_y+(showedges?int(16*mapscreen_single_scale):0);
5830 int w = 256*mapscreen_screenunit_scale*Map.getViewSize();
5831 int h = 176*mapscreen_screenunit_scale*Map.getViewSize();
5832
5833 MapViewRTI* rti_map_view = mapview_get_rti();
5834 rti_map_view->flags = Flags;
5835 rti_map_view->set_transform({.x = startxint, .y = startyint, .xscale = (float)mapscreen_single_scale, .yscale = (float)mapscreen_single_scale});
5836 rti_map_view->set_size(w, h);
5837 rti_map_view->dirty = true;
5838 rti_map_view->freeze = false;
5839 // TODO: could be improved. This currently makes the transform dirty every frame.
5840 get_root_rti()->add_child_before(rti_map_view, get_screen_rti());
5841 }
5842
5843 // Since the screen renders over the map view when HQR is enabled, the screen rti needs to be transparent.
5844 // But not if HQR is off, that would cause bugs when drawing color 0.
5845 get_screen_rti()->transparency_index = HighQualityScreenRendering ? 0 : -1;
5846
5847 for (auto& vis_screen : visible_screens)
5848 {
5849 draw_screenunit_map_screen(vis_screen);
5850 }
5851
5852 if (showxypos_icon)
5853 {
5854 int x0 = showxypos_x + (showedges?16:0);
5855 int y0 = showxypos_y + (showedges?16:0);
5856 int x1 = x0 + showxypos_w - 1;
5857 int y1 = y0 + showxypos_h - 1;
5858 x0 *= mapscreen_single_scale;
5859 y0 *= mapscreen_single_scale;
5860 x1 *= mapscreen_single_scale;
5861 y1 *= mapscreen_single_scale;
5862 x0 += mapscreen_x;
5863 y0 += mapscreen_y;
5864 x1 += mapscreen_x;
5865 y1 += mapscreen_y;
5866
5867 if (showxypos_color == vc(15))
5868 safe_rect(screen, x0, y0, x1, y1, showxypos_color);
5869 else
5870 rectfill(screen, x0, y0, x1, y1, showxypos_color);
5871 }
5872
5873 if(showxypos_cursor_icon)
5874 {
5875 int x0 = showxypos_cursor_x + (showedges?16:0);
5876 int y0 = showxypos_cursor_y + (showedges?16:0);
5877 int x1 = x0 + showxypos_w - 1;
5878 int y1 = y0 + showxypos_h - 1;
5879 x0 *= mapscreen_single_scale;
5880 y0 *= mapscreen_single_scale;
5881 x1 *= mapscreen_single_scale;
5882 y1 *= mapscreen_single_scale;
5883 x0 += mapscreen_x;
5884 y0 += mapscreen_y;
5885 x1 += mapscreen_x;
5886 y1 += mapscreen_y;
5887 safe_rect(screen, x0, y0, x1, y1, showxypos_cursor_color);
5888 }
5889
5890 // Draw dithering over the edge/preview combos.
5891 if(showedges)
5892 {
5893 int tile_size = 16 * mapscreen_single_scale;
5894 int tiles_across = (16 * Map.getViewSize()) + 2;
5895 int bottom_row_y = (Map.getViewSize()*11 + 1) * tile_size;
5896 int right_col_x = (Map.getViewSize()*16 + 1) * tile_size;
5897
5898 //top preview
5899 for(int32_t j=0; j<tile_size; j++)
5900 {
5901 for(int32_t i=0; i<tiles_across * tile_size; i++)
5902 {
5903 if(((i^j)&1)==0)
5904 {
5905 putpixel(screen,mapscreen_x+i,mapscreen_y+j,vc(0));
5906 }
5907 }
5908 }
5909
5910 //bottom preview
5911 for(int32_t j = bottom_row_y; j < bottom_row_y + tile_size; j++)
5912 {
5913 for(int32_t i=0; i<tiles_across * tile_size; i++)
5914 {
5915 if(((i^j)&1)==0)
5916 {
5917 putpixel(screen,mapscreen_x+i,mapscreen_y+j,vc(0));
5918 }
5919 }
5920 }
5921
5922 //left preview
5923 for(int32_t j=tile_size; j<int32_t(192*mapscreen_screenunit_scale); j++)
5924 {
5925 for(int32_t i=0; i<16*mapscreen_single_scale; i++)
5926 {
5927 if(((i^j)&1)==0)
5928 {
5929 putpixel(screen,mapscreen_x+i,mapscreen_y+j,vc(0));
5930 }
5931 }
5932 }
5933
5934 //right preview
5935 for(int32_t j=tile_size; j<int32_t(192*mapscreen_screenunit_scale); j++)
5936 {
5937 for(int32_t i = right_col_x; i < right_col_x + tile_size; i++)
5938 {
5939 if(((i^j)&1)==0)
5940 {
5941 putpixel(screen,mapscreen_x+i,mapscreen_y+j,vc(0));
5942 }
5943 }
5944 }
5945 }
5946
5947 if(!(Flags&cDEBUG) && pixeldb==2)
5948 {
5949 for(int32_t j=int32_t(168*mapscreen_single_scale); j<int32_t(176*mapscreen_single_scale); j++)
5950 {
5951 for(int32_t i=0; i<int32_t(256*mapscreen_single_scale); i++)
5952 {
5953
5954 if(((i^j)&1)==0)
5955 {
5956 putpixel(screen,int32_t(mapscreen_x+(showedges?(16*mapscreen_single_scale):0)+i),
5957 int32_t(mapscreen_y+(showedges?(16*mapscreen_single_scale):0)+j),vc(blackout_color));
5958 }
5959 }
5960 }
5961 }
5962
5963 // TODO: This should move to `zmap::draw` (and delete the current code there doing a similar thing).
5964 if (Map.isDark(Map.getCurrScr()) && Map.getViewSize() == 1)
5965 {
5966 if((Flags&cNEWDARK) && get_qr(qr_NEW_DARKROOM))
5967 {
5968 BITMAP* tmpDark = create_bitmap_ex(8,16*16,16*11);
5969 BITMAP* tmpDarkTrans = create_bitmap_ex(8,16*16,16*11);
5970 BITMAP* tmpbuf = create_bitmap_ex(8,
5971 mapscreen_single_scale*(256+(showedges?32:0)),
5972 mapscreen_single_scale*(176+(showedges?32:0)));
5973 BITMAP* tmpbuf2 = create_bitmap_ex(8,
5974 mapscreen_single_scale*(256+(showedges?32:0)),
5975 mapscreen_single_scale*(176+(showedges?32:0)));
5976 int32_t darkCol = zinit.darkcol;
5977 switch(darkCol) //special cases
5978 {
5979 case BLACK:
5980 darkCol = vc(0);
5981 break;
5982 case WHITE:
5983 darkCol = vc(15);
5984 break;
5985 }
5986 clear_to_color(tmpDark, darkCol);
5987 clear_to_color(tmpDarkTrans, darkCol);
5988 clear_bitmap(tmpbuf);
5989 clear_bitmap(tmpbuf2);
5990 //Handle torch combos
5991 color_map = trans_table2;
5992 Map.draw_darkness(tmpDark, tmpDarkTrans);
5993 //
5994 mapscr* tmp = Map.CurrScr();
5995 if(tmp->flags9 & fDARK_DITHER)
5996 {
5997 ditherblit(tmpDark, tmpDark, 0, zinit.dither_type, zinit.dither_arg);
5998 ditherblit(tmpDarkTrans, tmpDarkTrans, 0, zinit.dither_type, zinit.dither_arg);
5999 }
6000
6001 if(mapscreen_single_scale == 1)
6002 {
6003 blit(tmpDark, tmpbuf, 0, 0, (showedges?16:0), (showedges?16:0), 16*16, 16*11);
6004 blit(tmpDarkTrans, tmpbuf2, 0, 0, (showedges?16:0), (showedges?16:0), 16*16, 16*11);
6005 }
6006 else
6007 {
6008 stretch_blit(tmpDark, tmpbuf, 0, 0, 16*16, 16*11,
6009 (showedges?16:0)*mapscreen_single_scale, (showedges?16:0)*mapscreen_single_scale,
6010 (16*16)*mapscreen_single_scale, (16*11)*mapscreen_single_scale);
6011 stretch_blit(tmpDarkTrans, tmpbuf2, 0, 0, 16*16, 16*11,
6012 (showedges?16:0)*mapscreen_single_scale, (showedges?16:0)*mapscreen_single_scale,
6013 (16*16)*mapscreen_single_scale, (16*11)*mapscreen_single_scale);
6014 }
6015
6016 if(tmp->flags9 & fDARK_TRANS)
6017 {
6018 draw_trans_sprite(screen, tmpbuf, mapscreen_x, mapscreen_y);
6019 }
6020 else
6021 {
6022 masked_blit(tmpbuf,screen,0,0,mapscreen_x,mapscreen_y,tmpbuf->w,tmpbuf->h);
6023 }
6024 draw_trans_sprite(screen, tmpbuf2, mapscreen_x, mapscreen_y);
6025 color_map = trans_table;
6026 //
6027 destroy_bitmap(tmpDark);
6028 destroy_bitmap(tmpDarkTrans);
6029 destroy_bitmap(tmpbuf);
6030 destroy_bitmap(tmpbuf2);
6031 }
6032 else if(!(Flags&cNODARK))
6033 {
6034 for(int32_t j=0; j<80*mapscreen_single_scale; j++)
6035 {
6036 for(int32_t i=0; i<(80*mapscreen_single_scale)-j; i++)
6037 {
6038 if(((i^j)&1)==0)
6039 {
6040 putpixel(screen,int32_t(mapscreen_x+(showedges?(16*mapscreen_single_scale):0))+i,
6041 int32_t(mapscreen_y+(showedges?(16*mapscreen_single_scale):0)+j),vc(blackout_color));
6042 }
6043 }
6044 }
6045 }
6046 }
6047
6048 double startx=mapscreen_x+(showedges?(16*mapscreen_single_scale):0);
6049 double starty=mapscreen_y+(showedges?(16*mapscreen_single_scale):0);
6050 bool inrect = isinRect(gui_mouse_x(),gui_mouse_y(),startx,starty,(startx+(256*mapscreen_screenunit_scale)-1),(starty+(176*mapscreen_screenunit_scale)-1));
6051
6052 if(!(flags&rNOCURSOR) && ((ComboBrush && !ComboBrushPause)||draw_mode==dm_alias) && inrect)
6053 {
6054 int mgridscale=16*mapscreen_single_scale;
6055 if(allowHideMouse)
6056 {
6057 if(arrowcursor)
6058 {
6059 arrowcursor = false;
6060 MouseSprite::set(ZQM_BLANK);
6061 }
6062 }
6063 else if(!arrowcursor)
6064 {
6065 arrowcursor = true;
6066 MouseSprite::set(ZQM_NORMAL);
6067 }
6068 ComboPosition pos = get_mapscreen_mouse_combo_pos();
6069 int32_t mx = pos.x * 16 * mapscreen_single_scale;
6070 int32_t my = pos.y * 16 * mapscreen_single_scale;
6071
6072 clear_bitmap(brushscreen);
6073 int32_t tempbw=BrushWidth;
6074 int32_t tempbh=BrushHeight;
6075
6076 if(draw_mode==dm_alias)
6077 {
6078 BrushWidth = combo_aliases[combo_apos].width+1;
6079 BrushHeight = combo_aliases[combo_apos].height+1;
6080 }
6081 else if(draw_mode == dm_cpool)
6082 {
6083 BrushWidth = BrushHeight = 1;
6084 combo_pool const& pool = combo_pools[combo_pool_pos];
6085 if(pool.valid())
6086 {
6087 int32_t cid = Combo;
6088 int8_t cset = CSet;
6089 pool.get_w_wrap(cid,cset,cpoolbrush_index/16); //divide to reduce speed
6090 put_combo(brushbmp,0,0,cid,cset,Flags&(cFLAGS|cWALK),0);
6091 }
6092 else clear_bitmap(brushbmp);
6093 }
6094 else if (draw_mode == dm_auto)
6095 {
6096 BrushWidth = BrushHeight = 1;
6097 }
6098
6099 stretch_blit(brushbmp, brushscreen, 0, 0, BrushWidth*16, BrushHeight*16, 0, 0, BrushWidth*mgridscale, BrushHeight*mgridscale);
6100 int float_offx = 0;
6101 int float_offy = 0;
6102
6103 if(FloatBrush)
6104 {
6105 float_offx = -SHADOW_DEPTH*mapscreen_single_scale;
6106 float_offy = -SHADOW_DEPTH*mapscreen_single_scale;
6107
6108 //shadow
6109 for(int x = 0; x < SHADOW_DEPTH*mapscreen_single_scale; ++x)
6110 for(int y = 0; y < (BrushHeight*mgridscale) + (SHADOW_DEPTH*mapscreen_single_scale); ++y)
6111 {
6112 if((((x^y)&1)==1) && y < 12*mgridscale)
6113 putpixel(brushscreen,x+(BrushWidth*mgridscale),y,vc(0));
6114 }
6115
6116 for(int x = 0; x < BrushWidth*mgridscale; ++x)
6117 for(int y = 0; y < SHADOW_DEPTH*mapscreen_single_scale; ++y)
6118 {
6119 if((((x^y)&1)==1) && x<16*mgridscale)
6120 putpixel(brushscreen,x,y+(BrushHeight*mgridscale),vc(0));
6121 }
6122 }
6123
6124 if(draw_mode==dm_alias)
6125 {
6126 combo_alias *combo = &combo_aliases[combo_apos];
6127
6128 if(BrushWidth > 1 && (alias_origin & 1)) //right-align
6129 float_offx -= (BrushWidth - 1) * mgridscale;
6130
6131 if(BrushHeight > 1 && (alias_origin & 2)) //bottom-align
6132 float_offy -= (BrushHeight - 1) * mgridscale;
6133 }
6134
6135 int bx = mapscreen_x + mx + float_offx + (showedges?(16*mapscreen_single_scale):0);
6136 int by = mapscreen_y + my + float_offy + (showedges?(16*mapscreen_single_scale):0);
6137 masked_blit(brushscreen, screen, 0, 0, bx, by, 16*mgridscale, 11*mgridscale);
6138 BrushWidth=tempbw;
6139 BrushHeight=tempbh;
6140 }
6141 else
6142 {
6143 if(!arrowcursor)
6144 {
6145 MouseSprite::set(ZQM_NORMAL);
6146 arrowcursor = true;
6147 }
6148 }
6149
6150 int startxint = mapscreen_x+(showedges?int(16*mapscreen_single_scale):0);
6151 int startyint = mapscreen_y+(showedges?int(16*mapscreen_single_scale):0);
6152 int endxint = startx + 256*mapscreen_screenunit_scale - 1;
6153 int endyint = starty + 176*mapscreen_screenunit_scale - 1;
6154 set_clip_rect(screen,startxint,startyint,endxint,endyint);
6155
6156 if(ShowGrid)
6157 {
6158 int w = num_combos_width;
6159 int h = num_combos_height;
6160 double tile_size = 16.0 / Map.getViewSize() * mapscreen_screenunit_scale;
6161
6162 if(showedges)
6163 {
6164 w += 2;
6165 h += 2;
6166 }
6167
6168 for (int x = 1; x < w; x++)
6169 {
6170 vline(screen, mapscreen_x + x*tile_size, mapscreen_y, mapscreen_y + (h*tile_size)-1, vc(GridColor));
6171 }
6172
6173 for (int y = 1; y < h; y++)
6174 {
6175 hline(screen, mapscreen_x, mapscreen_y + y*tile_size, mapscreen_x + (w*tile_size)-1, vc(GridColor));
6176 }
6177 }
6178
6179 if(ShowScreenGrid)
6180 {
6181 int w = num_combos_width;
6182 int h = num_combos_height;
6183 double tile_size = 16.0 / Map.getViewSize() * mapscreen_screenunit_scale;
6184 int startx = mapscreen_x + (showedges ? (16 * mapscreen_single_scale) : 0);
6185 int starty = mapscreen_y + (showedges ? (16 * mapscreen_single_scale) : 0);
6186
6187 if(showedges)
6188 {
6189 w += 1;
6190 h += 1;
6191 }
6192
6193 int color = (GridColor+8)%16;
6194
6195 for (int x = 16; x < w; x+=16)
6196 {
6197 vline(screen, startx + x*tile_size, mapscreen_y, starty + (h*tile_size)-1, vc(color));
6198 }
6199
6200 for (int y = 11; y < h; y+=11)
6201 {
6202 hline(screen, startx, starty + y*tile_size, startx + (w*tile_size)-1, vc(color));
6203 }
6204 }
6205
6206 // Draw a rect around regions.
6207 if (ShowRegionGrid && Map.getViewSize() > 1)
6208 {
6209 for (const auto& region_description : Map.get_region_descriptions())
6210 {
6211 int sx = region_description.screen % 16;
6212 int sy = region_description.screen / 16;
6213 int sw = region_description.w;
6214 int sh = region_description.h;
6215
6216 int mw = 256 * mapscreen_single_scale;
6217 int mh = 176 * mapscreen_single_scale;
6218 int mx = sx - (Map.getViewScr() % 16);
6219 int my = sy - (Map.getViewScr() / 16);
6220 int x0 = mapscreen_x + (showedges ? (16 * mapscreen_single_scale) : 0) + mx * mw;
6221 int y0 = mapscreen_y + (showedges ? (16 * mapscreen_single_scale) : 0) + my * mh;
6222 rect(screen, x0+2, y0+2, x0 + mw*sw - 2, y0 + mh*sh - 2, vc(1));
6223 rect(screen, x0+1, y0+1, x0 + mw*sw - 1, y0 + mh*sh - 1, vc(15));
6224 rect(screen, x0, y0, x0 + mw*sw, y0 + mh*sh, vc(1));
6225 }
6226 }
6227
6228 // Draw a black-yellow-black rect around the currently selected screen.
6229 if (ShowCurScreenOutline && Map.getViewSize() > 1)
6230 {
6231 int mw = 256 * mapscreen_single_scale;
6232 int mh = 176 * mapscreen_single_scale;
6233 int mx = (Map.getCurrScr() % 16) - (Map.getViewScr() % 16);
6234 int my = (Map.getCurrScr() / 16) - (Map.getViewScr() / 16);
6235 int x0 = mapscreen_x + (showedges ? (16 * mapscreen_single_scale) : 0) + mx * mw;
6236 int y0 = mapscreen_y + (showedges ? (16 * mapscreen_single_scale) : 0) + my * mh;
6237 dotted_rect(screen, x0+2, y0+2, x0 + mw - 2, y0 + mh - 2, vc(1), vc(0));
6238 rect(screen, x0+1, y0+1, x0 + mw - 1, y0 + mh - 1, vc(14));
6239 dotted_rect(screen, x0, y0, x0 + mw, y0 + mh, vc(1), vc(0));
6240 }
6241
6242 clear_clip_rect(screen);
6243
6244 // Map tabs
6245 font = get_custom_font(CFONT_GUI);
6246
6247 map_page[current_mappage].map=Map.getCurrMap();
6248 map_page[current_mappage].screen=Map.getCurrScr();
6249
6250 for(int32_t btn=0; btn<mappage_count; ++btn)
6251 {
6252 char tbuf[15];
6253 sprintf(tbuf, "%d:%02X", map_page[btn].map+1, map_page[btn].screen);
6254 draw_layer_button(screen,map_page_bar[btn].x, map_page_bar[btn].y, map_page_bar[btn].w, map_page_bar[btn].h,tbuf,(btn==current_mappage?D_SELECTED:0));
6255 }
6256 }
6257 break;
6258 case rCOMBOS:
6259 {
6260 auto real_h = combolist_window.h;
6261 jwin_draw_frame(screen,combolist_window.x,combolist_window.y,combolist_window.w,real_h, FR_WIN);
6262 rectfill(screen,combolist_window.x+2,combolist_window.y+2,combolist_window.x+combolist_window.w-3,combolist_window.y+real_h-3,jwin_pal[jcBOX]);
6263
6264 //Scrollers
6265 for(int32_t c = 0; c < num_combo_cols; ++c)
6266 {
6267 auto& pos = combolistscrollers[c];
6268
6269 { //Scroll up
6270 auto& p = pos.subsquare(0);
6271 jwin_draw_frame(screen,p.x,p.y,p.w,p.h,FR_ETCHED);
6272
6273 for(int32_t i=0; i<3; i++)
6274 {
6275 hline(screen, p.x+5-i, p.y+4+i, p.x+5+i, jwin_pal[jcBOXFG]);
6276 }
6277 }
6278
6279 { //Scroll down
6280 auto& p = pos.subsquare(1);
6281 jwin_draw_frame(screen,p.x,p.y,p.w,p.h,FR_ETCHED);
6282
6283 for(int32_t i=0; i<3; i++)
6284 {
6285 hline(screen,p.x+5-i,p.y+6-i, p.x+5+i, jwin_pal[jcBOXFG]);
6286 }
6287 }
6288 }
6289
6290 if(draw_mode==dm_alias)
6291 {
6292 if(LinkedScroll)
6293 {
6294 int tmp = current_comboalist;
6295 for(int q = tmp-1; q >= 0; --q)
6296 {
6297 combo_alistpos[q] = combo_alistpos[q+1]-(comboaliaslist[q].w*comboaliaslist[q].h);
6298 if(combo_alistpos[q] < 0)
6299 {
6300 tmp = 0;
6301 combo_alistpos[0] = 0;
6302 break;
6303 }
6304 }
6305 for(int q = tmp+1; q < num_combo_cols; ++q)
6306 combo_alistpos[q] = combo_alistpos[q-1]+(comboaliaslist[q-1].w*comboaliaslist[q-1].h);
6307 for(int q = 0; q < num_combo_cols; ++q)
6308 if(combo_apos >= combo_alistpos[q] && combo_apos < combo_alistpos[q] + (comboaliaslist[q].w*comboaliaslist[q].h))
6309 {
6310 current_comboalist = q;
6311 break;
6312 }
6313 }
6314 for(int32_t c = 0; c < num_combo_cols; ++c)
6315 {
6316 auto& pos = comboaliaslist[c];
6317 rectfill(screen,pos.x,pos.y,pos.x+(pos.w*pos.xscale)-1,pos.y+(pos.h*pos.yscale)-1,0);
6318 jwin_draw_frame(screen,pos.x-2,pos.y-2,(pos.w*pos.xscale)+4,(pos.h*pos.yscale)+4,FR_DEEP);
6319 }
6320
6321 auto& prev = comboalias_preview;
6322 jwin_draw_frame(screen, prev.x-2, prev.y-2, prev.w+4, prev.h+4,FR_DEEP);
6323
6324 BITMAP *prv = create_bitmap_ex(8,64,64);
6325 clear_bitmap(prv);
6326 int32_t scalefactor = 1;
6327
6328 for(int32_t j=0; j<num_combo_cols; ++j)
6329 {
6330 auto per_page = (comboaliaslist[j].w * comboaliaslist[j].h);
6331 if(combo_alistpos[j] + per_page >= MAXCOMBOALIASES)
6332 combo_alistpos[j] = MAXCOMBOALIASES-per_page;
6333 auto& col = comboaliaslist[j];
6334 for(int32_t i=0; i<(comboaliaslist[j].w*comboaliaslist[j].h); i++)
6335 {
6336 draw_combo_alias_thumbnail(screen, &combo_aliases[combo_alistpos[j]+i],
6337 (i%col.w)*col.xscale+col.x, (i/col.w)*col.yscale+col.y, col.xscale/16);
6338 }
6339
6340 if((combo_aliases[combo_apos].width>7)||(combo_aliases[combo_apos].height>7))
6341 {
6342 scalefactor=4;
6343 }
6344 else if((combo_aliases[combo_apos].width>3)||(combo_aliases[combo_apos].height>3))
6345 {
6346 scalefactor=2;
6347 }
6348
6349
6350 if(j==current_comboalist)
6351 {
6352 stretch_blit(brushbmp, prv, 0,0,scalefactor*64,zc_min(scalefactor*64,176),0,0,64,scalefactor==4?44:64);
6353 blit(prv,screen,0,0,comboalias_preview.x,comboalias_preview.y,comboalias_preview.w,comboalias_preview.h);
6354
6355 int32_t rect_pos=combo_apos-combo_alistpos[current_comboalist];
6356
6357 if((rect_pos>=0)&&(rect_pos<(combo_alistpos[current_comboalist]+(col.w*col.h))))
6358 {
6359 int selw = col.xscale;
6360 int selh = col.yscale;
6361 int x1 = (rect_pos&(col.w-1))*col.xscale+col.x;
6362 int y1 = (rect_pos/col.w)*col.yscale+col.y;
6363 safe_rect(screen,x1,y1,x1+selw-1,y1+selh-1,vc(CmbCursorCol),2);
6364 }
6365 }
6366 }
6367
6368 destroy_bitmap(prv);
6369 }
6370 else if(draw_mode==dm_cpool)
6371 {
6372 if(LinkedScroll)
6373 {
6374 int tmp = current_cpoollist;
6375 for(int q = tmp-1; q >= 0; --q)
6376 {
6377 combo_pool_listpos[q] = combo_pool_listpos[q+1]-(comboaliaslist[q].w*comboaliaslist[q].h);
6378 if(combo_pool_listpos[q] < 0)
6379 {
6380 tmp = 0;
6381 combo_pool_listpos[0] = 0;
6382 break;
6383 }
6384 }
6385 for(int q = tmp+1; q < num_combo_cols; ++q)
6386 combo_pool_listpos[q] = combo_pool_listpos[q-1]+(comboaliaslist[q-1].w*comboaliaslist[q-1].h);
6387 for(int q = 0; q < num_combo_cols; ++q)
6388 if(combo_pool_pos >= combo_pool_listpos[q] && combo_pool_pos < combo_pool_listpos[q] + (comboaliaslist[q].w*comboaliaslist[q].h))
6389 {
6390 current_cpoollist = q;
6391 break;
6392 }
6393 }
6394 for(int32_t c = 0; c < num_combo_cols; ++c)
6395 {
6396 auto& pos = comboaliaslist[c];
6397 rectfill(screen,pos.x,pos.y,pos.x+(pos.w*pos.xscale)-1,pos.y+(pos.h*pos.yscale)-1,0);
6398 jwin_draw_frame(screen,pos.x-2,pos.y-2,(pos.w*comboaliaslist[c].xscale)+4,(pos.h*comboaliaslist[c].yscale)+4,FR_DEEP);
6399 }
6400
6401 for (int32_t j = 0; j < num_combo_cols; ++j) //the actual panes
6402 {
6403 auto per_page = (comboaliaslist[j].w * comboaliaslist[j].h);
6404 if(combo_pool_listpos[j] + per_page >= MAXCOMBOPOOLS)
6405 combo_pool_listpos[j] = MAXCOMBOPOOLS-per_page;
6406 for(int32_t i=0; i<(comboaliaslist[j].w*comboaliaslist[j].h); i++)
6407 {
6408 int32_t cid=-1; int8_t cs=CSet;
6409 combo_pool const& cp = combo_pools[combo_pool_listpos[j]+i];
6410
6411 auto& list = comboaliaslist[j];
6412 if(cp.get_w(cid,cs,0) && !combobuf[cid].tile)
6413 {
6414 cid = -1; //no tile to draw
6415 }
6416 auto cx = (i%list.w)*list.xscale+list.x;
6417 auto cy = (i/list.w)*list.yscale+list.y;
6418 put_combo(screen,cx,cy,cid,cs,Flags&(cFLAGS|cWALK),0,list.xscale/16);
6419 }
6420 }
6421 int32_t rect_pos=combo_pool_pos-combo_pool_listpos[current_cpoollist];
6422
6423 if((rect_pos>=0)&&(rect_pos<(combo_pool_listpos[current_cpoollist]+(comboaliaslist[current_cpoollist].w*comboaliaslist[current_cpoollist].h))))
6424 {
6425 int selw = comboaliaslist[current_cpoollist].xscale;
6426 int selh = comboaliaslist[current_cpoollist].yscale;
6427 int x1 = (rect_pos&(comboaliaslist[current_cpoollist].w-1))*comboaliaslist[current_cpoollist].xscale+comboaliaslist[current_cpoollist].x;
6428 int y1 = (rect_pos/comboaliaslist[current_cpoollist].w)*comboaliaslist[current_cpoollist].yscale+comboaliaslist[current_cpoollist].y;
6429 safe_rect(screen,x1,y1,x1+selw-1,y1+selh-1,vc(CmbCursorCol),2);
6430 }
6431
6432 //Handle Preview
6433 combo_pool const& cpool = combo_pools[combo_pool_pos];
6434
6435 int32_t cid; int8_t cs;
6436 size_t total = weighted_cpool ? cpool.getTotalWeight() : cpool.combos.size();
6437 size_t ind = 0;
6438 size_t indw = combopool_preview.w/16;
6439 size_t indh = combopool_preview.h/16;
6440 size_t rows = total ? vbound(total/indw,1,indh) : 0;
6441 if (is_compact)
6442 rows = vbound(rows, 1, 3);
6443 else
6444 rows = vbound(rows, 1, 4);
6445 size_t real_height = rows*16;
6446
6447 cpool_prev_visible = rows > 0;
6448 if(rows)
6449 {
6450 jwin_draw_frame(screen,combopool_preview.x-2,combopool_preview.y-2,
6451 combopool_preview.w+4,real_height+4,FR_DEEP);
6452 rectfill(screen,combopool_preview.x,combopool_preview.y,
6453 combopool_preview.x+combopool_preview.w-1,
6454 combopool_preview.y+real_height-1,vc(0));
6455 draw_text_button(screen,combopool_prevbtn.x,combopool_prevbtn.y,
6456 combopool_prevbtn.w,combopool_prevbtn.h,
6457 weighted_cpool ? "Weighted" : "Unweighted",vc(1),vc(14),0,true);
6458 if(!is_compact)
6459 textprintf_ex(screen,font,combopool_prevbtn.x+combopool_prevbtn.w+5,
6460 combopool_prevbtn.y,jwin_pal[jcBOXFG],-1,"Preview");
6461 for(auto y = 0; y < real_height; y += 16)
6462 {
6463 for(auto x = 0; x < combopool_preview.w; x += 16, ++ind)
6464 {
6465 auto nx = combopool_preview.x+x, ny = combopool_preview.y+y;
6466 if(ind < total)
6467 {
6468 cs = CSet;
6469 if(weighted_cpool
6470 ? cpool.get_w(cid,cs,ind)
6471 : cpool.get_ind(cid,cs,ind))
6472 {
6473 put_combo(screen,nx,ny,cid,cs,Flags&(cFLAGS|cWALK),0);
6474 continue;
6475 }
6476 }
6477 //No combo to display
6478 xout(screen, nx, ny, nx+15, ny+15, vc(15));
6479 }
6480 }
6481 }
6482 }
6483 else if (draw_mode == dm_auto)
6484 {
6485 if (LinkedScroll)
6486 {
6487 int tmp = current_cautolist;
6488 for (int q = tmp - 1; q >= 0; --q)
6489 {
6490 combo_auto_listpos[q] = combo_auto_listpos[q + 1] - (comboaliaslist[q].w * comboaliaslist[q].h);
6491 if (combo_auto_listpos[q] < 0)
6492 {
6493 tmp = 0;
6494 combo_auto_listpos[0] = 0;
6495 break;
6496 }
6497 }
6498 for (int q = tmp + 1; q < num_combo_cols; ++q)
6499 combo_auto_listpos[q] = combo_auto_listpos[q - 1] + (comboaliaslist[q - 1].w * comboaliaslist[q - 1].h);
6500 for (int q = 0; q < num_combo_cols; ++q)
6501 if (combo_auto_pos >= combo_auto_listpos[q] && combo_auto_pos < combo_auto_listpos[q] + (comboaliaslist[q].w * comboaliaslist[q].h))
6502 {
6503 current_cautolist = q;
6504 break;
6505 }
6506 }
6507 for (int32_t c = 0; c < num_combo_cols; ++c)
6508 {
6509 auto& pos = comboaliaslist[c];
6510 rectfill(screen, pos.x, pos.y, pos.x + (pos.w * pos.xscale) - 1, pos.y + (pos.h * pos.yscale) - 1, 0);
6511 jwin_draw_frame(screen, pos.x - 2, pos.y - 2, (pos.w * comboaliaslist[c].xscale) + 4, (pos.h * comboaliaslist[c].yscale) + 4, FR_DEEP);
6512 }
6513
6514 for (int32_t j = 0; j < num_combo_cols; ++j) //the actual panes
6515 {
6516 auto per_page = (comboaliaslist[j].w * comboaliaslist[j].h);
6517 if(combo_auto_listpos[j] + per_page >= MAXAUTOCOMBOS)
6518 combo_auto_listpos[j] = MAXAUTOCOMBOS-per_page;
6519 for (int32_t i = 0; i < (comboaliaslist[j].w * comboaliaslist[j].h); i++)
6520 {
6521 int32_t cid = -1; int8_t cs = CSet;
6522 combo_auto const& ca = combo_autos[combo_auto_listpos[j] + i];
6523
6524 auto& list = comboaliaslist[j];
6525 cid = ca.getDisplay();
6526 if (cid == 0)
6527 cid = -1;
6528 auto cx = (i % list.w) * list.xscale + list.x;
6529 auto cy = (i / list.w) * list.yscale + list.y;
6530 put_combo(screen, cx, cy, cid, cs, Flags & (cFLAGS | cWALK), 0, list.xscale / 16);
6531 put_autocombo_engravings(screen, ca, combo_auto_listpos[j] + i == combo_auto_pos, cx, cy, list.xscale / 16);
6532 }
6533 }
6534 int32_t rect_pos = combo_auto_pos - combo_auto_listpos[current_cautolist];
6535
6536 if ((rect_pos >= 0) && (rect_pos < (combo_auto_listpos[current_cautolist] + (comboaliaslist[current_cautolist].w * comboaliaslist[current_cautolist].h))))
6537 {
6538 int selw = comboaliaslist[current_cautolist].xscale;
6539 int selh = comboaliaslist[current_cautolist].yscale;
6540 int x1 = (rect_pos & (comboaliaslist[current_cautolist].w - 1)) * comboaliaslist[current_cautolist].xscale + comboaliaslist[current_cautolist].x;
6541 int y1 = (rect_pos / comboaliaslist[current_cautolist].w) * comboaliaslist[current_cautolist].yscale + comboaliaslist[current_cautolist].y;
6542 safe_rect(screen, x1, y1, x1 + selw - 1, y1 + selh - 1, vc(CmbCursorCol), 2);
6543
6544 combo_auto const& ca = combo_autos[combo_auto_pos];
6545 put_autocombo_engravings(screen, ca, true, x1, y1, selw / 16);
6546 }
6547 }
6548 else
6549 {
6550 if(LinkedScroll)
6551 {
6552 int tmp = current_combolist;
6553 for(int q = tmp-1; q >= 0; --q)
6554 {
6555 First[q] = First[q+1]-(combolist[q].w*combolist[q].h);
6556 if(First[q] < 0)
6557 {
6558 tmp = 0;
6559 First[0] = 0;
6560 break;
6561 }
6562 }
6563 for(int q = tmp+1; q < num_combo_cols; ++q)
6564 First[q] = First[q-1]+(combolist[q-1].w*combolist[q-1].h);
6565 for(int q = 0; q < num_combo_cols; ++q)
6566 if(Combo >= First[q] && Combo < First[q] + (combolist[q].w*combolist[q].h))
6567 {
6568 current_combolist = q;
6569 break;
6570 }
6571 }
6572 for(int32_t c = 0; c < num_combo_cols; ++c)
6573 {
6574 auto& pos = combolist[c];
6575 rectfill(screen,pos.x,pos.y,pos.x+(pos.w*pos.xscale)-1,pos.y+(pos.h*pos.yscale)-1,0);
6576 jwin_draw_frame(screen,pos.x-2,pos.y-2,(pos.w*pos.xscale)+4,(pos.h*pos.yscale)+4,FR_DEEP);
6577 }
6578
6579 int32_t drawmap, drawscr;
6580 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
6581 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
6582
6583 for(int32_t j=0; j<num_combo_cols; ++j)
6584 {
6585 auto per_page = (combolist[j].w * combolist[j].h);
6586 if(First[j] + per_page >= MAXCOMBOS)
6587 First[j] = MAXCOMBOS-per_page;
6588 for(int32_t i=0; i<(combolist[j].w*combolist[j].h); i++)
6589 {
6590 put_combo(screen,(i%combolist[j].w)*combolist[j].xscale+combolist[j].x,
6591 (i/combolist[j].w)*combolist[j].yscale+combolist[j].y,
6592 i+First[j],CSet,Flags&(cFLAGS|cWALK),0,combolist[j].xscale/16);
6593 }
6594 }
6595
6596 int32_t rect_pos=Combo-First[current_combolist];
6597
6598 if((rect_pos>=0)&&(rect_pos<(combo_pool_listpos[current_combolist]+(combolist[current_combolist].w*combolist[current_combolist].h))))
6599 {
6600 int selw = (AutoBrush?BrushWidth:1)*combolist[current_combolist].xscale;
6601 int selh = (AutoBrush?BrushHeight:1)*combolist[current_combolist].yscale;
6602 int x1 = (rect_pos&(combolist[current_combolist].w-1))*combolist[current_combolist].xscale+combolist[current_combolist].x;
6603 int y1 = (rect_pos/combolist[current_combolist].w)*combolist[current_combolist].yscale+combolist[current_combolist].y;
6604 safe_rect(screen,x1,y1,x1+selw-1,y1+selh-1,vc(CmbCursorCol),2);
6605 }
6606 }
6607 }
6608 break;
6609 case rCOMBO:
6610 {
6611 int32_t drawmap, drawscr;
6612 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
6613 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
6614
6615 // Combo preview
6616 int32_t cid = Combo; int8_t cs = CSet;
6617 if(draw_mode == dm_alias)
6618 {
6619 cid = combo_aliases[combo_apos].combos[0];
6620 cs = wrap(combo_aliases[combo_apos].csets[0]+alias_cset_mod, 0, 13);
6621 }
6622 else if(draw_mode == dm_cpool)
6623 {
6624 combo_pool const& cpool = combo_pools[combo_pool_pos];
6625 cid = 0;
6626 cpool.get_w(cid,cs,0);
6627 }
6628 else if (draw_mode == dm_auto)
6629 {
6630 combo_auto const& cauto = combo_autos[combo_auto_pos];
6631 cid = cauto.getDisplay();
6632 }
6633 static BITMAP *combo_preview_bmp=create_bitmap_ex(8,32,32);
6634 static BITMAP *cycle_preview_bmp=create_bitmap_ex(8,32,32);
6635 // Combo
6636 put_combo(combo_preview_bmp,0,0,cid,cs,Flags&(cFLAGS|cWALK),0);
6637 jwin_draw_frame(screen,combo_preview.x-2,combo_preview.y-2,combo_preview.w+4,combo_preview.h+4, FR_DEEP);
6638 stretch_blit(combo_preview_bmp, screen, 0, 0, 16, 16, combo_preview.x, combo_preview.y, combo_preview.w, combo_preview.h);
6639
6640 comboprev_buf[0] = 0;
6641 comboprev_buf2[0] = 0;
6642 if(draw_mode == dm_cpool)
6643 {
6644 sprintf(comboprev_buf,"Pool: %d\nCSet: %d",combo_pool_pos,CSet);
6645 int x = combo_preview_text1.x+(combo_preview_text1.w*combo_preview_text1.xscale);
6646 textbox_out(screen,txfont,x,combo_preview_text1.y,jwin_pal[jcBOXFG],jwin_pal[jcBOX],comboprev_buf,2,&combo_preview_text1);
6647 }
6648 else if (draw_mode == dm_auto)
6649 {
6650 GUI::ListData ac_types = GUI::ZCListData::autocombotypes();
6651 std::string type_name = ac_types.findText(combo_autos[combo_auto_pos].getType());
6652 if (is_compact)
6653 sprintf(comboprev_buf, "AC: %d CS: %d\n%s", combo_auto_pos, CSet, type_name.c_str());
6654 else
6655 sprintf(comboprev_buf, "Auto: %d CSet: %d\n%s\nEntries: %d", combo_auto_pos, CSet, type_name.c_str(), int32_t(combo_autos[combo_auto_pos].combos.size()));
6656 int x = combo_preview_text1.x + (combo_preview_text1.w * combo_preview_text1.xscale);
6657 textbox_out(screen, txfont, x, combo_preview_text1.y, jwin_pal[jcBOXFG], jwin_pal[jcBOX], comboprev_buf, 2, &combo_preview_text1);
6658 }
6659 else if(draw_mode != dm_alias)
6660 {
6661 int x = combo_preview_text1.x+(combo_preview_text1.w*combo_preview_text1.xscale);
6662
6663 char shortbuf[512];
6664 char buf[256];
6665 strcpy(buf,combo_class_buf[combobuf[Combo].type].name);
6666 sprintf(comboprev_buf,"Combo: %d\nCSet: %d\n%s",Combo,CSet,buf);
6667 int ind = strlen(buf)-1;
6668 int x2 = x;
6669 if(x2 - text_length(txfont, buf) <= combolist_window.x)
6670 {
6671 auto dotlen = text_length(txfont, "..");
6672 x2 -= dotlen;
6673 while(x2 - text_length(txfont, buf) <= combolist_window.x)
6674 {
6675 if(ind < 0) break;
6676 buf[ind--] = '\0';
6677 }
6678 while(ind >= 0 && buf[ind] == ' ')
6679 buf[ind--] = 0; //trim spaces
6680 strcat(buf, "..");
6681 }
6682
6683 if(is_compact)
6684 {
6685 char b2[256];
6686 sprintf(b2, "Combo %d CS %d", Combo, CSet);
6687 if(x-text_length(txfont, b2) <= combolist_window.x)
6688 sprintf(b2, "Cmb %d CS %d", Combo, CSet);
6689 sprintf(shortbuf,"%s\n%s",b2,buf);
6690 }
6691 else sprintf(shortbuf,"Combo: %d\nCSet: %d\n%s",Combo,CSet,buf);
6692 textbox_out(screen,txfont,x,combo_preview_text1.y,jwin_pal[jcBOXFG],jwin_pal[jcBOX],shortbuf,2,&combo_preview_text1);
6693 }
6694
6695 // Cycle
6696 if(!is_compact)
6697 {
6698 int32_t NextCombo = combobuf[Combo].nextcombo;
6699 int32_t NextCSet = combobuf[Combo].nextcset;
6700 if(combobuf[Combo].animflags & AF_CYCLEUNDERCOMBO)
6701 {
6702 mapscr* scr = Map.CurrScr();
6703 NextCombo = scr->undercombo;
6704 NextCSet = scr->undercset;
6705 }
6706 if(combobuf[Combo].animflags & AF_CYCLENOCSET)
6707 NextCSet = CSet;
6708 bool normal_dm = draw_mode != dm_alias && draw_mode != dm_cpool && draw_mode != dm_auto;
6709 jwin_draw_frame(screen,combo_preview2.x-2,combo_preview2.y-2,combo_preview2.w+4,combo_preview2.h+4, FR_DEEP);
6710 if(NextCombo>0 && normal_dm)
6711 {
6712 put_combo(cycle_preview_bmp,0,0,NextCombo,NextCSet,Flags&(cFLAGS|cWALK),0);
6713
6714 if(Flags&cWALK) put_walkflags(cycle_preview_bmp,0,0,NextCombo,0);
6715
6716 if(Flags&cFLAGS) put_flags(cycle_preview_bmp,0,0,NextCombo,0,cFLAGS,0);
6717
6718 stretch_blit(cycle_preview_bmp, screen, 0, 0, 16, 16, combo_preview2.x, combo_preview2.y, combo_preview2.w, combo_preview2.h);
6719 }
6720 else
6721 {
6722 if (InvalidBG == 2)
6723 {
6724 draw_checkerboard(screen, combo_preview2.x, combo_preview2.y, 32);
6725 }
6726 else if(InvalidBG == 1)
6727 {
6728 draw_static_pos(combo_preview2);
6729 }
6730 else
6731 {
6732 rectfill(screen, combo_preview2.x,combo_preview2.y, combo_preview2.x+32,combo_preview2.y+combo_preview2.h,vc(0));
6733 safe_rect(screen, combo_preview2.x,combo_preview2.y, combo_preview2.x+32,combo_preview2.y+combo_preview2.h,vc(15));
6734 line(screen, combo_preview2.x,combo_preview2.y, combo_preview2.x+32,combo_preview2.y+combo_preview2.h,vc(15));
6735 line(screen, combo_preview2.x,combo_preview2.y+combo_preview2.h, combo_preview2.x+32,combo_preview2.y,vc(15));
6736 }
6737 }
6738
6739 if(normal_dm)
6740 {
6741 char shortbuf[512];
6742 char buf[256];
6743 strcpy(buf,combo_class_buf[combobuf[NextCombo].type].name);
6744 sprintf(comboprev_buf2, "Cycle: %d\nCSet: %d\n%s", NextCombo, NextCSet, buf);
6745 int ind = strlen(buf)-1;
6746 int x2 = combo_preview_text2.x;
6747 if(x2 + text_length(txfont, buf) > zq_screen_w-2)
6748 {
6749 auto dotlen = text_length(txfont, "..");
6750 x2 += dotlen;
6751 while(x2 + text_length(txfont, buf) > zq_screen_w-2)
6752 {
6753 if(ind < 0) break;
6754 buf[ind--] = '\0';
6755 }
6756 while(ind >= 0 && buf[ind] == ' ')
6757 buf[ind--] = 0; //trim spaces
6758 strcat(buf, "..");
6759 }
6760
6761 sprintf(shortbuf, "Cycle: %d\nCSet: %d\n%s", NextCombo, NextCSet, buf);
6762 textbox_out(screen,txfont,combo_preview_text2.x,combo_preview_text2.y,jwin_pal[jcBOXFG],jwin_pal[jcBOX],shortbuf,0,&combo_preview_text2);
6763 }
6764 }
6765
6766 font = get_zc_font(font_lfont_l);
6767 bool merged = is_compact ? compact_merged_combopane : large_merged_combopane;
6768 draw_text_button(screen,combo_merge_btn.x,combo_merge_btn.y,combo_merge_btn.w,combo_merge_btn.h,merged ? "<|>" : ">|<",vc(1),vc(14),0,true);
6769 }
6770 break;
6771 case rFAVORITES:
6772 {
6773 font = get_zc_font(font_lfont_l);
6774
6775 jwin_draw_frame(screen,favorites_window.x,favorites_window.y,favorites_window.w,favorites_window.h, FR_WIN);
6776 rectfill(screen,favorites_window.x+2,favorites_window.y+2,favorites_window.x+favorites_window.w-3,favorites_window.y+favorites_window.h-3,jwin_pal[jcBOX]);
6777 jwin_draw_frame(screen,favorites_list.x-2,favorites_list.y-2,(favorites_list.w*favorites_list.xscale)+4,(favorites_list.h*favorites_list.yscale)+4, FR_DEEP);
6778 rectfill(screen,favorites_list.x,favorites_list.y,favorites_list.x+(favorites_list.w*favorites_list.xscale)-1,favorites_list.y+(favorites_list.h*favorites_list.yscale)-1,jwin_pal[jcBOXFG]);
6779
6780 textprintf_ex(screen,get_zc_font(font_lfont_l),favorites_list.x-2,favorites_list.y-15,jwin_pal[jcBOXFG],-1,is_compact ? "Favorites" : "Favorite Combos");
6781 BITMAP* subb = create_bitmap_ex(8,16,16);
6782
6783 for(int32_t col=0; col<favorites_list.w; ++col)
6784 {
6785 for(int32_t row=0; row<favorites_list.h; ++row)
6786 {
6787 auto i = (row*FAVORITECOMBO_PER_ROW)+col+FAVORITECOMBO_PER_PAGE*FavoriteComboPage;
6788 auto& sqr = favorites_list.subsquare(col,row);
6789 if(i >= MAXFAVORITECOMBOS || favorite_combos[i]==-1)
6790 {
6791 if (InvalidBG == 2)
6792 {
6793 draw_checkerboard(screen, sqr.x, sqr.y, sqr.w);
6794 }
6795 else if(InvalidBG == 1)
6796 {
6797 draw_static_pos(sqr);
6798 }
6799 else
6800 {
6801 xout(screen, sqr.x, sqr.y, sqr.x+sqr.w-1, sqr.y+sqr.h-1, vc(15), vc(0));
6802 }
6803 }
6804 else
6805 {
6806 clear_bitmap(subb);
6807 bool repos = combotile_override_x < 0 && combotile_override_y < 0;
6808
6809 switch(favorite_combo_modes[i])
6810 {
6811 case dm_alias:
6812 draw_combo_alias_thumbnail(subb, &combo_aliases[favorite_combos[i]], 0, 0, 1);
6813 if (ShowFavoriteComboModes)
6814 put_engraving(subb, 0, 0, 0x3E, 1);
6815 break;
6816 case dm_cpool:
6817 {
6818 int32_t cid = -1; int8_t cs = CSet;
6819 combo_pool const& cp = combo_pools[favorite_combos[i]];
6820
6821 if (cp.get_w(cid, cs, 0) && !combobuf[cid].tile)
6822 cid = -1; //no tile to draw
6823 put_combo(subb, 0, 0, cid, cs, 0, 0);
6824 if (ShowFavoriteComboModes)
6825 put_engraving(subb, 0, 0, 0x3D, 1);
6826 break;
6827 }
6828 case dm_auto:
6829 {
6830 int32_t cid = -1; int8_t cs = CSet;
6831 combo_auto const& ca = combo_autos[favorite_combos[i]];
6832
6833 cid = ca.getDisplay();
6834 if (cid == 0)
6835 cid = -1;
6836 put_combo(subb, 0, 0, cid, cs, 0, 0);
6837 if (ShowFavoriteComboModes)
6838 put_engraving(subb, 0, 0, 0x3C, 1);
6839 break;
6840 }
6841 default:
6842 if (repos)
6843 {
6844 combotile_override_x = sqr.x + (sqr.w - 16) / 2;
6845 combotile_override_y = sqr.y + (sqr.h - 16) / 2;
6846 }
6847 put_combo(subb, 0, 0, favorite_combos[i], CSet, Flags & (cFLAGS | cWALK), 0);
6848 if (repos) combotile_override_x = combotile_override_y = -1;
6849 }
6850 stretch_blit(subb, screen, 0, 0, 16, 16, sqr.x, sqr.y, sqr.w, sqr.h);
6851 }
6852 }
6853 }
6854
6855 destroy_bitmap(subb);
6856
6857 bool zoomed = is_compact ? compact_zoomed_fav : large_zoomed_fav;
6858 if(!is_compact)
6859 textprintf_right_ex(screen, get_zc_font(font_lfont_l), favorites_pgleft.x - 2, favorites_pgleft.y, jwin_pal[jcBOXFG], -1, "%d/9", FavoriteComboPage + 1);
6860
6861 draw_text_button(screen, favorites_pgleft.x, favorites_pgleft.y, favorites_pgleft.w, favorites_pgleft.h, is_compact ? "<" : "<-", vc(1), vc(14), 0, true);
6862 draw_text_button(screen, favorites_pgright.x, favorites_pgright.y, favorites_pgright.w, favorites_pgright.h, is_compact ? ">" : "->", vc(1), vc(14), 0, true);
6863 draw_text_button(screen,favorites_zoombtn.x,favorites_zoombtn.y,favorites_zoombtn.w,favorites_zoombtn.h,zoomed ? "-" : "+",vc(1),vc(14),0,true);
6864 draw_text_button(screen,favorites_x.x,favorites_x.y,favorites_x.w,favorites_x.h,"X",vc(1),vc(14),0,true);
6865 draw_text_button(screen,favorites_infobtn.x,favorites_infobtn.y,favorites_infobtn.w,favorites_infobtn.h,"?",vc(1),vc(14),0,true);
6866 }
6867 break;
6868 case rCOMMANDS:
6869 {
6870 jwin_draw_frame(screen,commands_window.x,commands_window.y,commands_window.w,commands_window.h, FR_WIN);
6871 rectfill(screen,commands_window.x+2,commands_window.y+2,commands_window.x+commands_window.w-3,commands_window.y+commands_window.h-3,jwin_pal[jcBOX]);
6872 jwin_draw_frame(screen,commands_list.x-2,commands_list.y-2,(commands_list.w*commands_list.xscale)+4,(commands_list.h*commands_list.yscale)+4, FR_DEEP);
6873 rectfill(screen,commands_list.x,commands_list.y,commands_list.x+(commands_list.w*commands_list.xscale)-1,commands_list.y+(commands_list.h*commands_list.yscale)-1,jwin_pal[jcBOXFG]);
6874 font=get_custom_font(CFONT_FAVCMD);
6875
6876 for(int32_t cmd=0; cmd<(commands_list.w*commands_list.h); ++cmd)
6877 {
6878 uint hkey = favorite_commands[cmd];
6879 draw_layer_button(screen,
6880 (cmd%commands_list.w)*commands_list.xscale+commands_list.x,
6881 (cmd/commands_list.w)*commands_list.yscale+commands_list.y,
6882 commands_list.xscale,
6883 commands_list.yscale,
6884 get_hotkey_name(hkey),
6885 (selected_hotkey(hkey)?D_SELECTED:0) | (disabled_hotkey(hkey)?D_DISABLED:0));
6886 }
6887
6888 font = get_zc_font(font_lfont_l);
6889 if(commands_txt.x > 0)
6890 {
6891 gui_textout_ln(screen, get_zc_font(font_lfont_l), (ucc*)"Favorite Commands", commands_txt.x, commands_txt.y, jwin_pal[jcBOXFG], -1, 0);
6892 }
6893
6894 bool zoomed = is_compact ? compact_zoomed_cmd : large_zoomed_cmd;
6895 draw_text_button(screen,commands_zoombtn.x,commands_zoombtn.y,commands_zoombtn.w,commands_zoombtn.h,zoomed ? "-" : "+",vc(1),vc(14),0,true);
6896 draw_text_button(screen,commands_x.x,commands_x.y,commands_x.w,commands_x.h,"X",vc(1),vc(14),0,true);
6897 draw_text_button(screen,commands_infobtn.x,commands_infobtn.y,commands_infobtn.w,commands_infobtn.h,"?",vc(1),vc(14),0,true);
6898 }
6899 break;
6900 }
6901 font = tfont;
6902 }
6903
6904 bool pause_refresh = true;
6905 bool is_refreshing = false;
6906 11 void refresh(int32_t flags, bool update)
6907 {
6908
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(pause_refresh) return;
6909 static bool refreshing = false;
6910
6911 int num_screens_to_draw = Map.getViewSize();
6912
6913 bool earlyret = refreshing;
6914 is_refreshing = refreshing = true;
6915 //^ These prevent recursive calls from updating the screen early
6916
6917 bool zoom_delay = (zoomed_minimap && flags != rSCRMAP);
6918 if(zoom_delay)
6919 flags &= ~rSCRMAP;
6920
6921 if(flags&rCLEAR)
6922 {
6923 //magic pink = 0xED
6924 //system black = vc(0)
6925 //Clear a4 menu
6926 // clear_to_color(screen,jwin_pal[jcBOX]);
6927 clear_to_color(screen,0);
6928
6929 //Clears should refresh everything!
6930 flags |= rALL;
6931 }
6932
6933 if(flags&rSCRMAP)
6934 draw_screenunit(rSCRMAP,flags);
6935
6936 if(flags&rMAP)
6937 draw_screenunit(rMAP,flags);
6938
6939 if((flags&rCOMBOS) || (draw_mode == dm_cpool && (flags&rFAVORITES)))
6940 draw_screenunit(rCOMBOS,flags);
6941
6942 if(flags&(rCOMBO|rCOMBOS))
6943 draw_screenunit(rCOMBO,flags);
6944
6945 if(flags&rMENU)
6946 drawpanel();
6947
6948 if(flags&rFAVORITES)
6949 draw_screenunit(rFAVORITES,flags);
6950
6951 if(flags&rCOMMANDS)
6952 draw_screenunit(rCOMMANDS,flags);
6953
6954 FONT* tfont = font;
6955 font = get_custom_font(CFONT_GUI);
6956 jwin_draw_frame(screen,layer_panel.x,layer_panel.y,layer_panel.w,layer_panel.h,FR_DEEP);
6957 rectfill(screen,layer_panel.x,layer_panel.y,layer_panel.x+layer_panel.w-1,layer_panel.y+layer_panel.h-1,jwin_pal[jcBOX]);
6958
6959 for(int32_t i=0; i<=6; ++i)
6960 {
6961 char tbuf[15];
6962
6963 if (i>0 && mapscreen_valid_layers[i - 1] && num_screens_to_draw == 1)
6964 {
6965 if(is_compact)
6966 sprintf(tbuf, "%s%d %d:%02X", (i==2 && Map.CurrScr()->flags7&fLAYER2BG) || (i==3 && Map.CurrScr()->flags7&fLAYER3BG) ? "-":"", i, Map.CurrScr()->layermap[i-1], Map.CurrScr()->layerscreen[i-1]);
6967 else sprintf(tbuf, "%s%d (%d:%02X)", (i==2 && Map.CurrScr()->flags7&fLAYER2BG) || (i==3 && Map.CurrScr()->flags7&fLAYER3BG) ? "-":"", i, Map.CurrScr()->layermap[i-1], Map.CurrScr()->layerscreen[i-1]);
6968 }
6969 else
6970 {
6971 sprintf(tbuf, "%s%d", (i==2 && Map.CurrScr()->flags7&fLAYER2BG) || (i==3 && Map.CurrScr()->flags7&fLAYER3BG) ? "-":"", i);
6972 }
6973
6974 int32_t spacing_offs = is_compact ? 2 : 10;
6975 int32_t rx = (i * (layerpanel_buttonwidth+spacing_offs+layerpanel_checkbox_wid)) + layer_panel.x+(is_compact?2:6);
6976 int32_t ry = layer_panel.y;
6977 auto cbyofs = (layerpanel_buttonheight-layerpanel_checkbox_hei)/2;
6978 draw_layer_button(screen, rx, ry, layerpanel_buttonwidth, layerpanel_buttonheight, tbuf, CurrentLayer==i? D_SELECTED : ( i > 0 && !mapscreen_valid_layers[i-1]) ? D_DISABLED : 0);
6979 draw_checkbox(screen,rx+layerpanel_buttonwidth+1,ry+cbyofs,layerpanel_checkbox_wid,layerpanel_checkbox_hei,LayerMaskInt[i]!=0);
6980 }
6981
6982 font=tfont;
6983
6984 // } //if(true)
6985 if(zq_showpal)
6986 {
6987 for(int32_t i=0; i<256; i++)
6988 {
6989 rectfill(screen,((i&15)<<2)+256,((i>>4)<<2)+176,((i&15)<<2)+259,((i>>4)<<2)+179,i);
6990 }
6991 }
6992 { //Show top-left info
6993 size_t maxwid = (mapscreen_screenunit_scale*mapscreenbmp->w)-1;
6994 size_t maxhei = (mapscreen_screenunit_scale*mapscreenbmp->w);
6995 set_clip_rect(screen,mapscreen_x,mapscreen_y,mapscreen_x+maxwid-1,mapscreen_y+maxhei-1);
6996 FONT* showfont = get_custom_font(CFONT_INFO);
6997 int showfont_h = text_height(showfont);
6998 int32_t ypos = mapscreen_y;
6999 if(prv_mode)
7000 {
7001 textout_shadowed_ex(screen,showfont,"Preview Mode",0,ypos,vc(15),vc(0),infobg?vc(0):-1);
7002 ypos += showfont_h+1;
7003 if(prv_twon)
7004 {
7005 textprintf_shadowed_ex(screen,showfont,0,ypos,vc(15),vc(0),infobg?vc(0):-1,"T Warp=%d tics", Map.get_prvtime());
7006 ypos += showfont_h+1;
7007 }
7008 }
7009 if(ShowFPS)
7010 {
7011 textprintf_shadowed_ex(screen,showfont,0,ypos,vc(15),vc(0),infobg?vc(0):-1,"FPS: %3d",lastfps);
7012 ypos += showfont_h+1;
7013 }
7014
7015 if(ShowFFScripts && !prv_mode)
7016 {
7017 word num_ffcs = Map.CurrScr()->numFFC();
7018 for(word i=0; i< num_ffcs; i++)
7019 {
7020 if(ypos+showfont_h-1 > map_page_bar[0].y)
7021 break;
7022 if(Map.CurrScr()->ffcs[i].script && Map.CurrScr()->ffcs[i].data)
7023 {
7024 textout_shadowed_ex(screen, showfont, ffcmap[Map.CurrScr()->ffcs[i].script-1].scriptname.substr(0,300).c_str(),0,ypos,vc(showxypos_ffc==i ? 14 : 15),vc(0),infobg?vc(0):-1);
7025 ypos+=showfont_h+1;
7026 }
7027 }
7028 }
7029 clear_clip_rect(screen);
7030 if(prv_mode)
7031 do_previewtext();
7032 }
7033 // Show Errors & Details
7034 //This includes the presence of: Screen State Carryover, Timed Warp, Maze Path, the 'Sideview Gravity', 'Invisible Hero',
7035 //'Save Screen', 'Continue Here' and 'Treat As..' Screen Flags,
7036 // the String, every Room Type and Catch All, and all four Tile and Side Warps.
7037 if(!prv_mode && ShowInfo)
7038 {
7039 int32_t i=0;
7040 char buf[2048];
7041
7042 // Start with general information
7043 if(Map.CurrScr()->flags3&fINVISHERO)
7044 {
7045 sprintf(buf,"Invisible Hero");
7046 show_screen_error(buf,i++,vc(15));
7047 }
7048
7049 if(Map.getLayerTargetMap() > 0)
7050 {
7051 Map.setlayertarget(); //Now the text does not carry over when changing maps, but shifting back, it does not **re-appear** until you change screens.
7052 //It was also required to set some updates in onDecMap and onIncMap. #
7053 //This fixes Screen Info not displaying properly when changing maps. -Z
7054 //Needed to refresh the screen info. -Z ( 26th March, 2019 )
7055 int32_t m = Map.getLayerTargetMultiple();
7056 sprintf(buf,"Used as a layer by screen %d:%02X",Map.getLayerTargetMap(),Map.getLayerTargetScr());
7057 char buf2[24];
7058
7059 if(m>0)
7060 {
7061 sprintf(buf2," and %d other%s",m,m>1?"s":"");
7062 strcat(buf,buf2);
7063 }
7064
7065 show_screen_error(buf,i++,vc(15));
7066 }
7067
7068 if(Map.CurrScr()->nextmap)
7069 {
7070 sprintf(buf,"Screen State carries over to %d:%02X",Map.CurrScr()->nextmap,Map.CurrScr()->nextscr);
7071 show_screen_error(buf,i++,vc(15));
7072 }
7073
7074 if(Map.CurrScr()->timedwarptics)
7075 {
7076 sprintf(buf,"%s%sTimed Warp: %s",(Map.CurrScr()->flags4&fTIMEDDIRECT)?"Direct ":"",(Map.CurrScr()->flags5&fRANDOMTIMEDWARP)?"Random ":"",ticksstr(Map.CurrScr()->timedwarptics));
7077 show_screen_error(buf,i++,vc(15));
7078 }
7079
7080 if(Map.CurrScr()->flags&fMAZE)
7081 {
7082 sprintf(buf,"Maze Path: %s (Exit %s)",pathstr(Map.CurrScr()->path),mazedirstr[Map.CurrScr()->exitdir]);
7083 show_screen_error(buf,i++,vc(15));
7084 }
7085
7086 bool continuescreen = false, savecombo = false;
7087
7088 if(Map.CurrScr()->flags4&fAUTOSAVE)
7089 {
7090 sprintf(buf,"Automatic Save%s Screen", (Map.CurrScr()->flags6&fCONTINUEHERE) ? "-Continue":"");
7091 show_screen_error(buf,i++,vc(15));
7092 continuescreen = ((Map.CurrScr()->flags6&fCONTINUEHERE)!=0);
7093 savecombo = true;
7094 }
7095 else if(Map.CurrScr()->flags6&fCONTINUEHERE)
7096 {
7097 sprintf(buf,"Continue Screen");
7098 show_screen_error(buf,i++,vc(15));
7099 continuescreen = true;
7100 }
7101
7102 if(isSideViewGravity())
7103 {
7104 sprintf(buf,"Sideview Gravity");
7105 show_screen_error(buf,i++,vc(15));
7106 }
7107
7108 if(Map.CurrScr()->flags6 & (fCAVEROOM|fDUNGEONROOM))
7109 {
7110 sprintf(buf,"Treat As %s%s Screen", (Map.CurrScr()->flags6&fCAVEROOM) ? "Interior":"NES Dungeon",
7111 (Map.CurrScr()->flags6 & (fCAVEROOM|fDUNGEONROOM)) == (fCAVEROOM|fDUNGEONROOM) ? " or NES Dungeon":"");
7112 show_screen_error(buf,i++,vc(15));
7113 }
7114
7115 if(Map.CurrScr()->oceansfx != 0)
7116 {
7117 sprintf(buf,"Ambient Sound: %s",sfx_string[Map.CurrScr()->oceansfx]);
7118 show_screen_error(buf,i++,vc(15));
7119 }
7120
7121 if(Map.CurrScr()->bosssfx != 0)
7122 {
7123 sprintf(buf,"Boss Roar Sound: %s",sfx_string[Map.CurrScr()->bosssfx]);
7124 show_screen_error(buf,i++,vc(15));
7125 }
7126
7127 if(Map.CurrScr()->str)
7128 {
7129 strncpy(buf,MsgString(Map.CurrScr()->str, true, false),72);
7130 buf[72] = '\0';
7131 char shortbuf[72];
7132 strip_extra_spaces(buf);
7133 shorten_string(shortbuf, buf, get_zc_font(font_lfont_l), 72, 280);
7134 sprintf(buf,"String %s",shortbuf);
7135 show_screen_error(buf,i++,vc(15));
7136 }
7137
7138 if((Map.CurrScr()->flags&fWHISTLE) || (Map.CurrScr()->flags7&fWHISTLEWATER))
7139 {
7140 sprintf(buf,"Whistle ->%s%s%s",(Map.CurrScr()->flags&fWHISTLE)?" Stairs":"",
7141 (Map.CurrScr()->flags&fWHISTLE && Map.CurrScr()->flags7&fWHISTLEWATER)?", ":"",
7142 (Map.CurrScr()->flags7&fWHISTLEWATER)?"Dry Lake":"");
7143 show_screen_error(buf,i++,vc(15));
7144 }
7145
7146 switch(Map.CurrScr()->room)
7147 {
7148 case rSP_ITEM:
7149 sprintf(buf,"Special Item is %s",item_string[Map.CurrScr()->catchall]);
7150 show_screen_error(buf,i++, vc(15));
7151 break;
7152
7153 case rINFO:
7154 {
7155 int32_t shop = Map.CurrScr()->catchall;
7156 sprintf(buf,"Pay For Info: -%d, -%d, -%d",
7157 QMisc.info[shop].price[0],QMisc.info[shop].price[1],QMisc.info[shop].price[2]);
7158 show_screen_error(buf,i++, vc(15));
7159 }
7160 break;
7161
7162 case rMONEY:
7163 sprintf(buf,"Secret Money: %d Rupees",Map.CurrScr()->catchall);
7164 show_screen_error(buf,i++, vc(15));
7165 break;
7166
7167 case rGAMBLE:
7168 show_screen_error("Gamble Room",i++, vc(15));
7169 break;
7170
7171 case rREPAIR:
7172 sprintf(buf,"Door Repair: -%d Rupees",Map.CurrScr()->catchall);
7173 show_screen_error(buf,i++, vc(15));
7174 break;
7175
7176 case rRP_HC:
7177 sprintf(buf,"Take %s or %s", item_string[iRPotion], item_string[iHeartC]);
7178 show_screen_error(buf,i++, vc(15));
7179 break;
7180
7181 case rGRUMBLE:
7182 show_screen_error("Feed the Goriya",i++, vc(15));
7183 break;
7184
7185 case rTRIFORCE:
7186 show_screen_error("Triforce Check",i++, vc(15));
7187 break;
7188
7189 case rP_SHOP:
7190 case rSHOP:
7191 {
7192 int32_t shop = Map.CurrScr()->catchall;
7193 sprintf(buf,"%sShop: ",
7194 Map.CurrScr()->room==rP_SHOP ? "Potion ":"");
7195
7196 for(int32_t j=0; j<3; j++) if(QMisc.shop[shop].item[j]>0) // Print the 3 items and prices
7197 {
7198 strcat(buf,item_string[QMisc.shop[shop].item[j]]);
7199 strcat(buf,":");
7200 char pricebuf[8];
7201 sprintf(pricebuf,"%d",QMisc.shop[shop].price[j]);
7202 strcat(buf,pricebuf);
7203
7204 if(j<2 && QMisc.shop[shop].item[j+1]>0) strcat(buf,", ");
7205 }
7206
7207 show_screen_error(buf,i++, vc(15));
7208 }
7209 break;
7210
7211 case rBOTTLESHOP:
7212 {
7213 int32_t shop = Map.CurrScr()->catchall;
7214 sprintf(buf,"Bottle Shop: ");
7215
7216 for(int32_t j=0; j<3; j++) if(QMisc.bottle_shop_types[shop].fill[j]>0) // Print the 3 fills and prices
7217 {
7218 strcat(buf,QMisc.bottle_types[QMisc.bottle_shop_types[shop].fill[j]-1].name);
7219 strcat(buf,":");
7220 char pricebuf[8];
7221 sprintf(pricebuf,"%d",QMisc.bottle_shop_types[shop].price[j]);
7222 strcat(buf,pricebuf);
7223
7224 if(j<2 && QMisc.bottle_shop_types[shop].fill[j+1]>0) strcat(buf,", ");
7225 }
7226
7227 show_screen_error(buf,i++, vc(15));
7228 }
7229 break;
7230
7231 case rTAKEONE:
7232 {
7233 int32_t shop = Map.CurrScr()->catchall;
7234 sprintf(buf,"Take Only One: %s%s%s%s%s",
7235 QMisc.shop[shop].item[0]<1?"":item_string[QMisc.shop[shop].item[0]],QMisc.shop[shop].item[0]>0?", ":"",
7236 QMisc.shop[shop].item[1]<1?"":item_string[QMisc.shop[shop].item[1]],(QMisc.shop[shop].item[1]>0&&QMisc.shop[shop].item[2]>0)?", ":"",
7237 QMisc.shop[shop].item[2]<1?"":item_string[QMisc.shop[shop].item[2]]);
7238 show_screen_error(buf,i++, vc(15));
7239 }
7240 break;
7241
7242 case rBOMBS:
7243 sprintf(buf,"More Bombs: -%d Rupees",Map.CurrScr()->catchall);
7244 show_screen_error(buf,i++, vc(15));
7245 break;
7246
7247 case rARROWS:
7248 sprintf(buf,"More Arrows: -%d Rupees",Map.CurrScr()->catchall);
7249 show_screen_error(buf,i++, vc(15));
7250 break;
7251
7252 case rSWINDLE:
7253 sprintf(buf,"Leave Life or %d Rupees",Map.CurrScr()->catchall);
7254 show_screen_error(buf,i++, vc(15));
7255 break;
7256
7257 case r10RUPIES:
7258 show_screen_error("10 Rupees",i++, vc(15));
7259 break;
7260
7261 case rGANON:
7262 show_screen_error("Ganon Room",i++, vc(15));
7263 break;
7264
7265 case rZELDA:
7266 show_screen_error("Zelda Room",i++, vc(15));
7267 break;
7268
7269 case rMUPGRADE:
7270 show_screen_error("1/2 Magic Upgrade",i++, vc(15));
7271 break;
7272
7273 case rLEARNSLASH:
7274 show_screen_error("Learn Slash",i++, vc(15));
7275 break;
7276
7277 case rWARP:
7278 sprintf(buf,"3-Stair Warp: Warp Ring %d",Map.CurrScr()->catchall);
7279 show_screen_error(buf,i++, vc(15));
7280 break;
7281 }
7282
7283 bool undercombo = false, warpa = false, warpb = false, warpc = false, warpd = false, warpr = false;
7284
7285 word num_ffcs = Map.CurrScr()->numFFC();
7286 for(int32_t c=0; c<176+128+1+num_ffcs; ++c)
7287 {
7288 // Checks both combos, secret combos, undercombos and FFCs
7289 //Fixme:
7290 int32_t ctype =
7291 combobuf[vbound(
7292 (c>=305 ? Map.CurrScr()->ffcs[c-305].data :
7293 c>=304 ? Map.CurrScr()->undercombo :
7294 c>=176 ? Map.CurrScr()->secretcombo[c-176] :
7295 !Map.CurrScr()->valid ? 0 : // Sanity check: does room combo data exist?
7296 Map.CurrScr()->data[c]
7297 ), 0, MAXCOMBOS-1)].type;
7298
7299 if(!undercombo && integrityBoolUnderCombo(Map.CurrScr(),ctype))
7300 {
7301 undercombo = true;
7302 show_screen_error("Under Combo is combo 0",i++, vc(7));
7303 }
7304
7305 // Tile Warp types
7306 switch(ctype)
7307 {
7308 case cSAVE:
7309 case cSAVE2:
7310 if(!savecombo)
7311 {
7312 savecombo = true;
7313
7314 if(integrityBoolSaveCombo(Map.CurrScr(),ctype))
7315 show_screen_error("Save Screen",i++, vc(15));
7316 else
7317 show_screen_error("Save-Continue Screen",i++, vc(15));
7318 }
7319
7320 break;
7321
7322 case cSTAIRR:
7323 case cPITR:
7324 case cSWARPR:
7325 if(!warpr && (Map.CurrScr()->tilewarptype[0]==wtCAVE || Map.CurrScr()->tilewarptype[1]==wtCAVE ||
7326 Map.CurrScr()->tilewarptype[2]==wtCAVE || Map.CurrScr()->tilewarptype[3]==wtCAVE))
7327 {
7328 warpr = true;
7329 show_screen_error("Random Tile Warp contains Cave/Item Cellar",i++, vc(7));
7330 }
7331
7332 break;
7333
7334 case cCAVED:
7335 case cPITD:
7336 case cSTAIRD:
7337 case cCAVE2D:
7338 case cSWIMWARPD:
7339 case cDIVEWARPD:
7340 case cSWARPD:
7341 if(!warpd)
7342 {
7343 warpd = true;
7344 tile_warp_notification(3,buf);
7345 show_screen_error(buf,i++, vc(15));
7346 }
7347
7348 break;
7349
7350 case cCAVEC:
7351 case cPITC:
7352 case cSTAIRC:
7353 case cCAVE2C:
7354 case cSWIMWARPC:
7355 case cDIVEWARPC:
7356 case cSWARPC:
7357 if(!warpc)
7358 {
7359 warpc = true;
7360 tile_warp_notification(2,buf);
7361 show_screen_error(buf,i++, vc(15));
7362 }
7363
7364 break;
7365
7366 case cCAVEB:
7367 case cPITB:
7368 case cSTAIRB:
7369 case cCAVE2B:
7370 case cSWIMWARPB:
7371 case cDIVEWARPB:
7372 case cSWARPB:
7373 if(!warpb)
7374 {
7375 warpb = true;
7376 tile_warp_notification(1,buf);
7377 show_screen_error(buf,i++, vc(15));
7378 }
7379
7380 break;
7381
7382 case cCAVE:
7383 case cPIT:
7384 case cSTAIR:
7385 case cCAVE2:
7386 case cSWIMWARP:
7387 case cDIVEWARP:
7388 case cSWARPA:
7389 if(!warpa)
7390 {
7391 warpa = true;
7392 tile_warp_notification(0,buf);
7393 show_screen_error(buf,i++, vc(15));
7394 }
7395
7396 break;
7397 }
7398 }
7399
7400 int32_t sidewarpnotify = 0;
7401
7402 if(Map.CurrScr()->flags2&wfUP)
7403 {
7404 side_warp_notification(Map.CurrScr()->sidewarpindex&3,0,buf);
7405 show_screen_error(buf,i++, vc(15));
7406 sidewarpnotify|=(1<<(Map.CurrScr()->sidewarpindex&3));
7407 }
7408
7409 if(Map.CurrScr()->flags2&wfDOWN)
7410 {
7411 side_warp_notification((Map.CurrScr()->sidewarpindex>>2)&3,1,buf);
7412 show_screen_error(buf,i++, vc(15));
7413 sidewarpnotify|=(1<<((Map.CurrScr()->sidewarpindex>>2)&3));
7414 }
7415
7416 if(Map.CurrScr()->flags2&wfLEFT)
7417 {
7418 side_warp_notification((Map.CurrScr()->sidewarpindex>>4)&3,2,buf);
7419 show_screen_error(buf,i++, vc(15));
7420 sidewarpnotify|=(1<<((Map.CurrScr()->sidewarpindex>>4)&3));
7421 }
7422
7423 if(Map.CurrScr()->flags2&wfRIGHT)
7424 {
7425 side_warp_notification((Map.CurrScr()->sidewarpindex>>6)&3,3,buf);
7426 show_screen_error(buf,i++, vc(15));
7427 sidewarpnotify|=(1<<((Map.CurrScr()->sidewarpindex>>6)&3));
7428 }
7429
7430 if(!(sidewarpnotify&1) && Map.CurrScr()->timedwarptics)
7431 {
7432 side_warp_notification(0,4,buf); // Timed Warp
7433 show_screen_error(buf,i++, vc(15));
7434 }
7435
7436 // Now for errors
7437 if((Map.CurrScr()->flags4&fSAVEROOM) && !savecombo) show_screen_error("Save Point->Continue Here, but no Save Point combo?",i++, vc(14));
7438
7439 if(integrityBoolEnemiesItem(Map.CurrScr())) show_screen_error("Enemies->Item, but no enemies",i++, vc(7));
7440
7441 if(integrityBoolEnemiesSecret(Map.CurrScr())) show_screen_error("Enemies->Secret, but no enemies",i++, vc(7));
7442
7443 if(integrityBoolGuyNoString(Map.CurrScr())) show_screen_error("Non-Fairy Guy, but String is (none)",i++, vc(14));
7444
7445 if(integrityBoolRoomNoGuy(Map.CurrScr())) show_screen_error("Guy is (none)",i++, vc(14));
7446
7447 if(integrityBoolRoomNoString(Map.CurrScr())) show_screen_error("String is (none)",i++, vc(14));
7448
7449 if(integrityBoolRoomNoGuyNoString(Map.CurrScr())) show_screen_error("Guy and String are (none)",i++, vc(14));
7450 }
7451
7452 if(zoom_delay)
7453 draw_screenunit(rSCRMAP,flags);
7454
7455 if(earlyret)
7456 return;
7457
7458 //Draw the Main Menu
7459 rectfill(screen,mainbar.x,mainbar.y,mainbar.x+mainbar.w-1,mainbar.y+mainbar.h-1,jwin_pal[jcBOX]);
7460 jwin_draw_frame(screen,mainbar.x,mainbar.y,mainbar.w,mainbar.h,FR_WIN);
7461
7462 FONT* oldfont = font;
7463 font = get_custom_font(CFONT_GUI);
7464
7465 //Drawmode button
7466 draw_text_button(screen,drawmode_btn.x,drawmode_btn.y,drawmode_btn.w,drawmode_btn.h,dm_names[draw_mode],vc(1),vc(14),0,true);
7467 //Compact button
7468 draw_text_button(screen,compactbtn.x, compactbtn.y, compactbtn.w, compactbtn.h, is_compact ? "< Expand" : "> Compact", vc(1),vc(14),0,true);
7469 //Zoom buttons
7470 zoom_in_btn_disabled = num_screens_to_draw == 1;
7471 zoom_out_btn_disabled = num_screens_to_draw == mapscreen_num_screens_to_draw_max;
7472 draw_text_button(screen,zoominbtn.x, zoominbtn.y, zoominbtn.w, zoominbtn.h, "+", vc(1),vc(14),zoom_in_btn_disabled ? D_DISABLED : 0,true);
7473 draw_text_button(screen,zoomoutbtn.x, zoomoutbtn.y, zoomoutbtn.w, zoomoutbtn.h, "-", vc(1),vc(14),zoom_out_btn_disabled ? D_DISABLED : 0,true);
7474
7475 font = oldfont;
7476
7477 d_nbmenu_proc(MSG_DRAW, &dialogs[0], 0);
7478
7479 ComboBrushPause=0;
7480
7481 if(update)
7482 custom_vsync();
7483 is_refreshing = refreshing = false;
7484 11 }
7485
7486 12 static int minimap_tooltip_id = ttip_register_id();
7487
7488 void select_scr()
7489 {
7490 if(Map.getCurrMap()>=Map.getMapCount())
7491 return;
7492
7493 int32_t tempcb=ComboBrush;
7494 ComboBrush=0;
7495
7496 size_and_pos const& real_mini = zoomed_minimap ? real_minimap_zoomed : real_minimap;
7497
7498 auto prev_cursor = Map.getCursor();
7499 Map.ConfigureCursorHistory(false);
7500
7501 //scooby
7502 while(gui_mouse_b())
7503 {
7504 int32_t x=gui_mouse_x();
7505 int32_t y=gui_mouse_y();
7506
7507 int32_t ind = real_mini.rectind(x,y);
7508
7509 if(ind>=MAPSCRS)
7510 ind-=16;
7511
7512 if(ind > -1 && ind != Map.getCurrScr())
7513 {
7514 Map.setCurrScr(ind);
7515 }
7516
7517 custom_vsync();
7518 refresh(rALL);
7519 }
7520
7521 ComboBrush=tempcb;
7522
7523 Map.ConfigureCursorHistory(true);
7524 if (prev_cursor != Map.getCursor())
7525 Map.pushCursorToHistory(prev_cursor);
7526 }
7527
7528 bool select_favorite()
7529 {
7530 int32_t tempcb=ComboBrush;
7531 ComboBrush=0;
7532 bool valid=false;
7533
7534 while(gui_mouse_b())
7535 {
7536 valid=false;
7537 int32_t x=gui_mouse_x();
7538
7539 if(x<favorites_list.x)
7540 x=favorites_list.x;
7541
7542 if(x>favorites_list.x+(favorites_list.w*favorites_list.xscale)-1)
7543 x=favorites_list.x+(favorites_list.w*favorites_list.xscale)-1;
7544
7545 int32_t y=gui_mouse_y();
7546
7547 if(y<favorites_list.y)
7548 y=favorites_list.y;
7549
7550 if(y>favorites_list.y+(favorites_list.h*favorites_list.yscale)-1)
7551 y=favorites_list.y+(favorites_list.h*favorites_list.yscale)-1;
7552
7553 int32_t tempc=(((y-favorites_list.y)/favorites_list.yscale)*FAVORITECOMBO_PER_ROW)+((x-favorites_list.x)/favorites_list.xscale) + FAVORITECOMBO_PER_PAGE * FavoriteComboPage;
7554
7555 if(tempc >= MAXFAVORITECOMBOS)
7556 {
7557 //Nothing, invalid
7558 }
7559 else
7560 {
7561 if(favorite_combos[tempc]!=-1)
7562 {
7563 switch(favorite_combo_modes[tempc])
7564 {
7565 case dm_alias:
7566 draw_mode = dm_alias;
7567 combo_apos = favorite_combos[tempc];
7568 break;
7569 case dm_cpool:
7570 draw_mode = dm_cpool;
7571 combo_pool_pos = favorite_combos[tempc];
7572 break;
7573 case dm_auto:
7574 draw_mode = dm_auto;
7575 combo_auto_pos = favorite_combos[tempc];
7576 break;
7577 default:
7578 draw_mode = dm_normal;
7579 Combo = favorite_combos[tempc];
7580 }
7581 if(AutoBrush)
7582 BrushWidth = BrushHeight = 1;
7583 valid=true;
7584 fix_drawing_mode_menu();
7585 }
7586 }
7587
7588 custom_vsync();
7589 refresh(rALL);
7590 }
7591
7592 ComboBrush=tempcb;
7593 return valid;
7594 }
7595
7596 void select_combo(int32_t clist)
7597 {
7598 current_combolist=clist;
7599 int32_t tempcb=ComboBrush;
7600 ComboBrush=0;
7601
7602 int autobrush_cx = -1, autobrush_cy = -1;
7603 int autobrush_first = First[current_combolist];
7604 auto& curlist = combolist[current_combolist];
7605 AutoBrushRevert = (key[KEY_ALT]||key[KEY_ALTGR]);
7606 while(gui_mouse_b())
7607 {
7608 int32_t x=gui_mouse_x();
7609
7610 if(x<curlist.x)
7611 x=curlist.x;
7612
7613 if(x>curlist.x+(curlist.w*curlist.xscale)-1)
7614 x=curlist.x+(curlist.w*curlist.xscale)-1;
7615
7616 int32_t y=gui_mouse_y();
7617
7618 if(y<curlist.y)
7619 y=curlist.y;
7620
7621 if(y>curlist.y+(curlist.h*curlist.yscale)-1)
7622 y=curlist.y+(curlist.h*curlist.yscale)-1;
7623
7624 int cx = ((x-curlist.x)/curlist.xscale), cy = ((y-curlist.y)/curlist.yscale);
7625 if(AutoBrush)
7626 {
7627 if(autobrush_cx < 0)
7628 {
7629 autobrush_cx = cx;
7630 autobrush_cy = cy;
7631 }
7632 BrushWidth = vbound(abs(autobrush_cx-cx)+1,1,16);
7633 BrushHeight = vbound(abs(autobrush_cy-cy)+1,1,11);
7634 cx = std::min(autobrush_cx,cx);
7635 cy = std::min(autobrush_cy,cy);
7636 }
7637 Combo=(cy*curlist.w)+cx+First[current_combolist];
7638 custom_vsync();
7639 refresh(rALL);
7640 if(AutoBrush) //Prevent any scrolling
7641 First[current_combolist] = autobrush_first;
7642 }
7643 if(key[KEY_ALT]||key[KEY_ALTGR])
7644 AutoBrushRevert = true;
7645 position_mouse_z(0);
7646 ComboBrush=tempcb;
7647 }
7648
7649 void select_comboa(int32_t clist)
7650 {
7651 current_comboalist=clist;
7652 int32_t tempcb=ComboBrush;
7653 ComboBrush=0;
7654 alias_cset_mod=0;
7655
7656 auto& curlist = comboaliaslist[current_comboalist];
7657 while(gui_mouse_b())
7658 {
7659 int32_t x=gui_mouse_x();
7660
7661 if(x<curlist.x)
7662 x=curlist.x;
7663
7664 if(x>curlist.x+(curlist.w*curlist.xscale)-1)
7665 x=curlist.x+(curlist.w*curlist.xscale)-1;
7666
7667 int32_t y=gui_mouse_y();
7668
7669 if(y<curlist.y)
7670 y=curlist.y;
7671
7672 if(y>curlist.y+(curlist.h*curlist.yscale)-1)
7673 y=curlist.y+(curlist.h*curlist.yscale)-1;
7674
7675 combo_apos=(((y-curlist.y)/curlist.yscale)*curlist.w)+((x-curlist.x)/curlist.xscale)+combo_alistpos[current_comboalist];
7676 custom_vsync();
7677 refresh(rALL);
7678 }
7679
7680 ComboBrush=tempcb;
7681 }
7682
7683 void select_combop(int32_t clist)
7684 {
7685 current_cpoollist=clist;
7686 int32_t tempcb=ComboBrush;
7687 ComboBrush=0;
7688
7689 auto& curlist = comboaliaslist[current_cpoollist];
7690 while(gui_mouse_b())
7691 {
7692 int32_t x=gui_mouse_x();
7693
7694 if(x<curlist.x) x=curlist.x;
7695
7696 if(x>curlist.x+(curlist.w*curlist.xscale)-1)
7697 x=curlist.x+(curlist.w*curlist.xscale)-1;
7698
7699 int32_t y=gui_mouse_y();
7700
7701 if(y<curlist.y) y=curlist.y;
7702
7703 if(y>curlist.y+(curlist.h*curlist.yscale)-1)
7704 y=curlist.y+(curlist.h*curlist.yscale)-1;
7705
7706 combo_pool_pos=(((y-curlist.y)/curlist.yscale)*curlist.w)+((x-curlist.x)/curlist.xscale)+combo_pool_listpos[current_cpoollist];
7707 custom_vsync();
7708 refresh(rALL);
7709 }
7710
7711 ComboBrush=tempcb;
7712 }
7713
7714 void select_autocombo(int32_t clist)
7715 {
7716 current_cautolist = clist;
7717 int32_t tempcb = ComboBrush;
7718 ComboBrush = 0;
7719
7720 auto& curlist = comboaliaslist[current_cautolist];
7721 while (gui_mouse_b())
7722 {
7723 int32_t x = gui_mouse_x();
7724
7725 if (x < curlist.x) x = curlist.x;
7726
7727 if (x > curlist.x + (curlist.w * curlist.xscale) - 1)
7728 x = curlist.x + (curlist.w * curlist.xscale) - 1;
7729
7730 int32_t y = gui_mouse_y();
7731
7732 if (y < curlist.y) y = curlist.y;
7733
7734 if (y > curlist.y + (curlist.h * curlist.yscale) - 1)
7735 y = curlist.y + (curlist.h * curlist.yscale) - 1;
7736
7737 combo_auto_pos = (((y - curlist.y) / curlist.yscale) * curlist.w) + ((x - curlist.x) / curlist.xscale) + combo_auto_listpos[current_cautolist];
7738 cauto_height = combo_autos[combo_auto_pos].getArg() + 1;
7739 custom_vsync();
7740 refresh(rALL);
7741 }
7742
7743 ComboBrush = tempcb;
7744 }
7745
7746 void update_combobrush()
7747 {
7748 clear_bitmap(brushbmp);
7749
7750 if(draw_mode==dm_alias)
7751 {
7752 //int32_t count=(combo_aliases[combo_apos].width+1)*(combo_aliases[combo_apos].height+1)*(comboa_lmasktotal(combo_aliases[combo_apos].layermask));
7753 for(int32_t z=0; z<=comboa_lmasktotal(combo_aliases[combo_apos].layermask); z++)
7754 {
7755 for(int32_t y=0; y<=combo_aliases[combo_apos].height; y++)
7756 {
7757 for(int32_t x=0; x<=combo_aliases[combo_apos].width; x++)
7758 {
7759 int32_t position = ((y*(combo_aliases[combo_apos].width+1))+x)+((combo_aliases[combo_apos].width+1)*(combo_aliases[combo_apos].height+1)*z);
7760
7761 if(combo_aliases[combo_apos].combos[position])
7762 {
7763 if(z==0)
7764 {
7765 putcombo(brushbmp,x<<4,y<<4,combo_aliases[combo_apos].combos[position],wrap(combo_aliases[combo_apos].csets[position]+alias_cset_mod, 0, 13));
7766 }
7767 else
7768 {
7769 overcombo(brushbmp,x<<4,y<<4,combo_aliases[combo_apos].combos[position],wrap(combo_aliases[combo_apos].csets[position]+alias_cset_mod, 0, 13));
7770 }
7771 }
7772 }
7773 }
7774 }
7775
7776 int xoff = 6, yoff = 6;
7777 if(FloatBrush) // Offset the floating pixels, so the 'x' appears centered on the combo still -Em
7778 {
7779 xoff += 2;
7780 yoff += 2;
7781 }
7782 if(alias_origin & 1) // Right-align
7783 xoff += combo_aliases[combo_apos].width*16;
7784 if(alias_origin & 2) // Bottom-align
7785 yoff += combo_aliases[combo_apos].height*16;
7786
7787 textprintf_shadowed_ex(brushbmp, get_zc_font(font_sfont), xoff, yoff, vc(15), vc(0), -1, "x");
7788 }
7789 else if(draw_mode != dm_cpool)
7790 {
7791 int32_t cid = combobrushoverride > -1 ? combobrushoverride : Combo;
7792 int32_t c = 0;
7793
7794 for(int32_t i=0; i<256; i++)
7795 {
7796 if(unsigned(cid+c) >= MAXCOMBOS) break;
7797 if(((i%COMBOS_PER_ROW)<BrushWidth)&&((i/COMBOS_PER_ROW)<BrushHeight))
7798 {
7799 put_combo(brushbmp,(i%COMBOS_PER_ROW)<<4,(i/COMBOS_PER_ROW)<<4,cid+c,CSet,Flags&(cFLAGS|cWALK),0);
7800 }
7801
7802 if(((cid+c)&3)==3)
7803 c+=48;
7804
7805 ++c;
7806
7807 if((i%COMBOS_PER_ROW)==(COMBOS_PER_ROW-1))
7808 c-=256;
7809 }
7810 }
7811 }
7812
7813 byte relational_source_grid[256]=
7814 {
7815 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
7816 16, 16, 17, 17, 18, 18, 19, 19, 16, 16, 17, 17, 18, 18, 19, 19,
7817 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 23, 23, 23, 23,
7818 24, 24, 24, 24, 25, 25, 25, 25, 24, 24, 24, 24, 25, 25, 25, 25,
7819 26, 27, 26, 27, 26, 27, 26, 27, 28, 29, 28, 29, 28, 29, 28, 29,
7820 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
7821 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
7822 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
7823 34, 35, 36, 37, 34, 35, 36, 37, 34, 35, 36, 37, 34, 35, 36, 37,
7824 38, 38, 39, 39, 38, 38, 39, 39, 38, 38, 39, 39, 38, 38, 39, 39,
7825 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
7826 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
7827 42, 43, 42, 43, 42, 43, 42, 43, 42, 43, 42, 43, 42, 43, 42, 43,
7828 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44,
7829 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
7830 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46
7831 };
7832
7833 static void draw_autocombo(ComboPosition combo_pos, bool rclick, bool pressframe = false)
7834 {
7835 combo_auto &ca = combo_autos[combo_auto_pos];
7836 int screen = Map.getScreenForPosition(combo_pos);
7837 int pos = combo_pos.truncate();
7838
7839 if (ca.valid())
7840 {
7841 switch (ca.getType())
7842 {
7843 case AUTOCOMBO_BASIC:
7844 {
7845 AutoPattern::autopattern_basic ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7846 if (rclick)
7847 ap.erase(screen, pos);
7848 else
7849 ap.execute(screen, pos);
7850 break;
7851 }
7852 case AUTOCOMBO_Z1:
7853 {
7854 AutoPattern::autopattern_flatmtn ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7855 if (rclick)
7856 ap.erase(screen, pos);
7857 else
7858 ap.execute(screen, pos);
7859 break;
7860 }
7861 case AUTOCOMBO_FENCE:
7862 {
7863 AutoPattern::autopattern_fence ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7864 if (rclick)
7865 ap.erase(screen, pos);
7866 else
7867 ap.execute(screen, pos);
7868 break;
7869 }
7870 case AUTOCOMBO_Z4:
7871 {
7872 AutoPattern::autopattern_cakemtn ap(ca.getType(), CurrentLayer, screen, pos, &ca, cauto_height);
7873 if (rclick)
7874 ap.erase(screen, pos);
7875 else
7876 ap.execute(screen, pos);
7877 break;
7878 }
7879 case AUTOCOMBO_RELATIONAL:
7880 {
7881 AutoPattern::autopattern_relational ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7882 if (rclick)
7883 ap.erase(screen, pos);
7884 else
7885 ap.execute(screen, pos);
7886 break;
7887 }
7888 case AUTOCOMBO_DGNCARVE:
7889 {
7890 AutoPattern::autopattern_dungeoncarve ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7891 if (rclick)
7892 ap.erase(screen, pos);
7893 else
7894 ap.execute(screen, pos);
7895 break;
7896 }
7897 case AUTOCOMBO_DOR:
7898 {
7899 AutoPattern::autopattern_dormtn ap(ca.getType(), CurrentLayer, screen, pos, &ca, cauto_height);
7900 if (rclick)
7901 ap.erase(screen, pos);
7902 else
7903 ap.execute(screen, pos);
7904 break;
7905 }
7906 case AUTOCOMBO_TILING:
7907 {
7908 if (pressframe && (key[KEY_LSHIFT] || key[KEY_RSHIFT]))
7909 {
7910 int32_t x = (screen % 16) * 16 + (pos % 16);
7911 int32_t y = (screen / 16) * 11 + (pos / 16);
7912 byte w = (ca.getArg() & 0xF) + 1;
7913 byte h = ((ca.getArg() >> 4) & 0xF) + 1;
7914 ca.setOffsets(x % w, y % h);
7915 }
7916 AutoPattern::autopattern_tiling ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7917 if (rclick)
7918 ap.erase(screen, pos);
7919 else
7920 ap.execute(screen, pos);
7921 break;
7922 }
7923 case AUTOCOMBO_REPLACE:
7924 {
7925 AutoPattern::autopattern_replace ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7926 if (rclick)
7927 ap.erase(screen, pos);
7928 else
7929 ap.execute(screen, pos);
7930 break;
7931 }
7932 case AUTOCOMBO_DENSEFOREST:
7933 {
7934 if (pressframe && (key[KEY_LSHIFT] || key[KEY_RSHIFT]))
7935 {
7936 int32_t x = (screen % 16) * 16 + (pos % 16);
7937 int32_t y = (screen / 16) * 11 + (pos / 16);
7938 ca.setOffsets(x % 2, y % 2);
7939 }
7940 AutoPattern::autopattern_denseforest ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7941 if (rclick)
7942 ap.erase(screen, pos);
7943 else
7944 ap.execute(screen, pos);
7945 break;
7946 }
7947 case AUTOCOMBO_EXTEND:
7948 {
7949 if (CHECK_CTRL_CMD)
7950 break;
7951 AutoPattern::autopattern_extend ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7952 if (rclick)
7953 ap.erase(screen, pos);
7954 else
7955 ap.execute(screen, pos);
7956 break;
7957 }
7958 }
7959 }
7960 else
7961 {
7962 ca.updateValid();
7963 if(!ca.valid())
7964 InfoDialog("Notice", "The autocombo you're trying to use is invalid. Reason:"
7965 + ca.getInvalidReason()).show();
7966 }
7967 }
7968
7969 static void draw_autocombo_command(ComboPosition combo_pos, int32_t cmd = 0, int32_t arg = 0)
7970 {
7971 combo_auto ca = combo_autos[combo_auto_pos];
7972 int screen = Map.getScreenForPosition(combo_pos);
7973 int pos = combo_pos.truncate();
7974
7975 if (ca.valid())
7976 {
7977 switch (ca.getType())
7978 {
7979 case AUTOCOMBO_FENCE:
7980 {
7981 AutoPattern::autopattern_fence ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7982 ap.flip_all_connected(screen, pos, 2048);
7983 break;
7984 }
7985 case AUTOCOMBO_Z4:
7986 {
7987 AutoPattern::autopattern_cakemtn ap(ca.getType(), CurrentLayer, screen, pos, &ca, cauto_height);
7988 switch (cmd)
7989 {
7990 case 0: // Flip
7991 ap.flip_all_connected(screen, pos, 2048);
7992 break;
7993 case 1: // Grow
7994 ap.resize_connected(screen, pos, 2048, vbound(arg, 1, 9));
7995 break;
7996 }
7997 }
7998 }
7999 }
8000 }
8001
8002 static int32_t get_autocombo_floating_cid(ComboPosition combo_pos, bool clicked)
8003 {
8004 combo_auto& ca = combo_autos[combo_auto_pos];
8005 int screen = Map.getScreenForPosition(combo_pos);
8006 int pos = combo_pos.truncate();
8007 int cid = 0;
8008
8009 if (ca.valid() && Map.isValidPosition(mouse_combo_pos))
8010 {
8011 switch (ca.getType())
8012 {
8013 case AUTOCOMBO_BASIC:
8014 {
8015 AutoPattern::autopattern_basic ap(ca.getType(), CurrentLayer, screen, pos, &ca);
8016 cid = ap.get_floating_cid(screen, pos);
8017 break;
8018 }
8019
8020 case AUTOCOMBO_Z1:
8021 {
8022 AutoPattern::autopattern_flatmtn ap(ca.getType(), CurrentLayer, screen, pos, &ca);
8023 cid = ap.get_floating_cid(screen, pos);
8024 break;
8025 }
8026 case AUTOCOMBO_FENCE:
8027 {
8028 AutoPattern::autopattern_fence ap(ca.getType(), CurrentLayer, screen, pos, &ca);
8029 cid = ap.get_floating_cid(screen, pos);
8030 break;
8031 }
8032 case AUTOCOMBO_Z4:
8033 {
8034 AutoPattern::autopattern_cakemtn ap(ca.getType(), CurrentLayer, screen, pos, &ca, cauto_height);
8035 cid = ap.get_floating_cid(screen, pos);
8036 break;
8037 }
8038 case AUTOCOMBO_RELATIONAL:
8039 {
8040 AutoPattern::autopattern_relational ap(ca.getType(), CurrentLayer, screen, pos, &ca);
8041 cid = ap.get_floating_cid(screen, pos);
8042 break;
8043 }
8044 case AUTOCOMBO_DGNCARVE:
8045 {
8046 AutoPattern::autopattern_dungeoncarve ap(ca.getType(), CurrentLayer, screen, pos, &ca);
8047 cid = ap.get_floating_cid(screen, pos);
8048 break;
8049 }
8050 case AUTOCOMBO_DOR:
8051 {
8052 AutoPattern::autopattern_dormtn ap(ca.getType(), CurrentLayer, screen, pos, &ca, cauto_height);
8053 cid = ap.get_floating_cid(screen, pos);
8054 break;
8055 }
8056 case AUTOCOMBO_TILING:
8057 {
8058 std::pair<byte, byte> offs = ca.getOffsets();
8059 if (!clicked && (key[KEY_LSHIFT] || key[KEY_RSHIFT]))
8060 {
8061 int32_t x = (screen % 16) * 16 + (pos % 16);
8062 int32_t y = (screen / 16) * 11 + (pos / 16);
8063 byte w = (ca.getArg() & 0xF) + 1;
8064 byte h = ((ca.getArg() >> 4) & 0xF) + 1;
8065 offs.first = (x % w);
8066 offs.second = (y % h);
8067 }
8068 AutoPattern::autopattern_tiling ap(ca.getType(), CurrentLayer, screen, pos, &ca);
8069 cid = ap.get_floating_cid(screen, pos);
8070 break;
8071 }
8072 case AUTOCOMBO_REPLACE:
8073 {
8074 AutoPattern::autopattern_replace ap(ca.getType(), CurrentLayer, screen, pos, &ca);
8075 cid = ap.get_floating_cid(screen, pos);
8076 break;
8077 }
8078 case AUTOCOMBO_DENSEFOREST:
8079 {
8080 AutoPattern::autopattern_denseforest ap(ca.getType(), CurrentLayer, screen, pos, &ca);
8081 cid = ap.get_floating_cid(screen, pos);
8082 break;
8083 }
8084 case AUTOCOMBO_EXTEND:
8085 {
8086 AutoPattern::autopattern_extend ap(ca.getType(), CurrentLayer, screen, pos, &ca);
8087 cid = ap.get_floating_cid(screen, pos);
8088 break;
8089 }
8090 }
8091 }
8092 return cid;
8093 }
8094
8095 void change_autocombo_height(int32_t change)
8096 {
8097 bool can_change = false;
8098 if (draw_mode == dm_auto)
8099 {
8100 combo_auto ca = combo_autos[combo_auto_pos];
8101 switch (ca.getType())
8102 {
8103 case AUTOCOMBO_Z4:
8104 can_change = true;
8105 [[fallthrough]];
8106 case AUTOCOMBO_DOR:
8107 break;
8108 default:
8109 return;
8110 }
8111 }
8112 else
8113 return;
8114
8115 int32_t x = gui_mouse_x();
8116 int32_t y = gui_mouse_y();
8117 double startx = mapscreen_x + (showedges ? (16 * mapscreen_single_scale) : 0);
8118 double starty = mapscreen_y + (showedges ? (16 * mapscreen_single_scale) : 0);
8119 int32_t startxint = mapscreen_x + (showedges ? int32_t(16 * mapscreen_single_scale) : 0);
8120 int32_t startyint = mapscreen_y + (showedges ? int32_t(16 * mapscreen_single_scale) : 0);
8121 ComboPosition pos = get_mapscreen_mouse_combo_pos();
8122
8123 if (can_change && isinRect(x, y, startxint, startyint, int32_t(startx + (256 * mapscreen_single_scale) - 1), int32_t(starty + (176 * mapscreen_single_scale) - 1)))
8124 {
8125 Map.StartListCommand();
8126 draw_autocombo_command(pos, 1, cauto_height + change);
8127 Map.FinishListCommand();
8128 }
8129 cauto_height = vbound(cauto_height + change, 1, 9);
8130 }
8131
8132 void draw(bool justcset)
8133 {
8134 combo_pool const& pool = combo_pools[combo_pool_pos];
8135 if(draw_mode == dm_cpool && !pool.valid())
8136 return;
8137 mark_save_dirty();
8138
8139 refresh(rMAP+rSCRMAP);
8140 ComboPosition last_pos = {-1, -1};
8141
8142 Map.StartListCommand();
8143 bool pressframe = true;
8144 while(gui_mouse_b())
8145 {
8146 int32_t x=gui_mouse_x();
8147 int32_t y=gui_mouse_y();
8148 double startx=mapscreen_x+(showedges?(16*mapscreen_single_scale):0);
8149 double starty=mapscreen_y+(showedges?(16*mapscreen_single_scale):0);
8150 int32_t startxint=mapscreen_x+(showedges?int32_t(16*mapscreen_single_scale):0);
8151 int32_t startyint=mapscreen_y+(showedges?int32_t(16*mapscreen_single_scale):0);
8152 int num_combos_width = 16 * Map.getViewSize();
8153 int num_combos_height = 11 * Map.getViewSize();
8154
8155 if(isinRect(x,y,startxint,startyint,int32_t(startx+(256*mapscreen_screenunit_scale)-1),int32_t(starty+(176*mapscreen_screenunit_scale)-1)))
8156 {
8157 int32_t cxstart=(x-startx)/(16*mapscreen_single_scale);
8158 int32_t cystart=(y-starty)/(16*mapscreen_single_scale);
8159 ComboPosition combo_start = {cxstart, cystart};
8160 if (pressframe)
8161 {
8162 last_pos = combo_start;
8163 }
8164 else if (combo_start == last_pos)
8165 {
8166 custom_vsync();
8167 refresh(rALL);
8168 continue;
8169 }
8170 else if(draw_mode == dm_auto)
8171 {
8172 // TODO: support when zoomed out.
8173 if (combo_autos[combo_auto_pos].getType() == AUTOCOMBO_FENCE || combo_autos[combo_auto_pos].getType() == AUTOCOMBO_Z4)
8174 {
8175 // Don't allow moving the brush at anything but cardinal directions while in these modes
8176 bool did_diag = std::abs(combo_start.x - last_pos.x) == 1 && std::abs(combo_start.y - last_pos.y) == 1;
8177
8178 if (did_diag)
8179 {
8180 int32_t oldx = last_pos.x;
8181 int32_t oldy = last_pos.y;
8182 int32_t cx = (oldx * 16 * mapscreen_single_scale) + 8;
8183 int32_t cy = (oldy * 16 * mapscreen_single_scale) + 8;
8184 int32_t nx = x - startxint;
8185 int32_t ny = y - startyint;
8186 if (std::abs(nx - cx) < std::abs(ny - cy))
8187 {
8188 oldy = vbound(oldy + ((ny - cy) < 0 ? -1 : 1), 0, 11);
8189 }
8190 else
8191 {
8192 oldx = vbound(oldx + ((nx - cx) < 0 ? -1 : 1), 0, 15);
8193 }
8194 combo_start = {oldx, oldy};
8195 }
8196 }
8197 }
8198 last_pos = combo_start;
8199
8200 switch(draw_mode)
8201 {
8202 case dm_normal:
8203 {
8204 int32_t cc=Combo;
8205
8206 for(int32_t cy=0; cy+cystart<num_combos_height&&cy<BrushHeight; cy++)
8207 {
8208 for(int32_t cx=0; cx+cxstart<num_combos_width&&cx<BrushWidth; cx++)
8209 {
8210 auto pos = combo_start + ComboPosition{cx, cy};
8211 cc=Combo + cx + cy*4;
8212 Map.DoSetComboCommand(pos, justcset ? -1 : cc, CSet);
8213 }
8214 }
8215
8216 update_combobrush();
8217 }
8218 break;
8219 case dm_cpool:
8220 {
8221 int32_t cid = Combo;
8222 int8_t cs = CSet;
8223 pool.pick(cid,cs);
8224 Map.DoSetComboCommand(combo_start, justcset ? -1 : cid, cs);
8225
8226 update_combobrush();
8227 }
8228 break;
8229
8230 case dm_alias:
8231 {
8232 combo_alias *combo = &combo_aliases[combo_apos];
8233 if(!combo->layermask)
8234 {
8235 int32_t ox=0, oy=0;
8236
8237 switch(alias_origin)
8238 {
8239 case 0:
8240 ox=0;
8241 oy=0;
8242 break;
8243
8244 case 1:
8245 ox=(combo->width);
8246 oy=0;
8247 break;
8248
8249 case 2:
8250 ox=0;
8251 oy=(combo->height);
8252 break;
8253
8254 case 3:
8255 ox=(combo->width);
8256 oy=(combo->height);
8257 break;
8258 }
8259
8260 for(int32_t cy=0; cy-oy+cystart<num_combos_height&&cy<=combo->height; cy++)
8261 {
8262 for(int32_t cx=0; cx-ox+cxstart<num_combos_width&&cx<=combo->width; cx++)
8263 {
8264 if((cx+cxstart-ox>=0)&&(cy+cystart-oy>=0))
8265 {
8266 int32_t p=(cy*(combo->width+1))+cx;
8267
8268 if(combo->combos[p])
8269 {
8270 auto pos = combo_start + ComboPosition{cx - ox, cy - oy};
8271 Map.DoSetComboCommand(pos, combo->combos[p], wrap(combo->csets[p]+alias_cset_mod, 0, 13));
8272 }
8273 }
8274 }
8275 }
8276 }
8277 else
8278 {
8279 int32_t laypos = 0;
8280 int32_t ox=0, oy=0;
8281
8282 switch(alias_origin)
8283 {
8284 case 0:
8285 ox=0;
8286 oy=0;
8287 break;
8288
8289 case 1:
8290 ox=(combo->width);
8291 oy=0;
8292 break;
8293
8294 case 2:
8295 ox=0;
8296 oy=(combo->height);
8297 break;
8298
8299 case 3:
8300 ox=(combo->width);
8301 oy=(combo->height);
8302 break;
8303 }
8304
8305 for(int32_t cz=0; cz<7; cz++)
8306 {
8307 if (cz > 0 && !(combo->layermask & (1<<(cz-1))))
8308 continue;
8309
8310 if (cz > 0)
8311 laypos++;
8312
8313 for(int32_t cy=0; cy-oy+cystart<num_combos_height&&cy<=combo->height; cy++)
8314 {
8315 for(int32_t cx=0; cx-ox+cxstart<num_combos_width&&cx<=combo->width; cx++)
8316 {
8317 if((cx+cxstart-ox>=0)&&(cy+cystart-oy>=0))
8318 {
8319 int32_t p=((cy*(combo->width+1))+cx)+((combo->width+1)*(combo->height+1)*laypos);
8320
8321 if (combo->combos[p])
8322 {
8323 auto pos = combo_start + ComboPosition{cx - ox, cy - oy};
8324 if(cz > 0 && Map.Scr(pos)->layermap[cz - 1] == 0)
8325 continue;
8326 int prev = CurrentLayer;
8327 CurrentLayer = cz;
8328 Map.DoSetComboCommand(pos, combo->combos[p], wrap(combo->csets[p]+alias_cset_mod, 0, 13));
8329 CurrentLayer = prev;
8330 }
8331 }
8332 }
8333 }
8334 }
8335 }
8336
8337 break;
8338 }
8339
8340 case dm_auto:
8341 {
8342 draw_autocombo(combo_start, gui_mouse_b() & 2, pressframe);
8343
8344 combobrushoverride = get_autocombo_floating_cid(combo_start, true);
8345 update_combobrush();
8346 }
8347 }
8348 }
8349 pressframe = false;
8350
8351 custom_vsync();
8352 refresh(rALL);
8353 }
8354
8355 Map.FinishListCommand();
8356 if(AutoBrushRevert)
8357 {
8358 AutoBrushRevert = false;
8359 BrushWidth = 1;
8360 BrushHeight = 1;
8361 }
8362 }
8363
8364 static void replace(ComboPosition start)
8365 {
8366 int32_t cid = Combo;
8367 int8_t cs = CSet;
8368 combo_pool const& pool = combo_pools[combo_pool_pos];
8369 if(draw_mode == dm_cpool && !pool.valid())
8370 return;
8371
8372 int c = start.truncate();
8373 mapscr* scr = Map.Scr(start, CurrentLayer);
8374 if (!scr) return;
8375
8376 int num_combos_width = 16 * Map.getViewSize();
8377 int num_combos_height = 11 * Map.getViewSize();
8378 int targetcombo = scr->data[c];
8379 int targetcset = scr->cset[c];
8380
8381 mark_save_dirty();
8382 Map.StartListCommand();
8383 if(key[KEY_LSHIFT] || key[KEY_RSHIFT])
8384 {
8385 for (int x = 0; x < num_combos_width; x++)
8386 {
8387 for (int y = 0; y < num_combos_height; y++)
8388 {
8389 ComboPosition pos = {x, y};
8390 int c = pos.truncate();
8391 mapscr* scr = Map.Scr(pos, CurrentLayer);
8392 if (!scr)
8393 continue;
8394
8395 if ((scr->cset[c]) == targetcset)
8396 {
8397 if(draw_mode == dm_cpool)
8398 pool.pick(cid,cs);
8399 Map.DoSetComboCommand(pos, -1, cs);
8400 }
8401 }
8402 }
8403 }
8404 else
8405 {
8406 for (int x = 0; x < num_combos_width; x++)
8407 {
8408 for (int y = 0; y < num_combos_height; y++)
8409 {
8410 ComboPosition pos = {x, y};
8411 int c = pos.truncate();
8412 mapscr* scr = Map.Scr(pos, CurrentLayer);
8413 if (!scr)
8414 continue;
8415
8416 if(((scr->data[c])==targetcombo) &&
8417 ((scr->cset[c])==targetcset))
8418 {
8419 if(draw_mode == dm_cpool)
8420 pool.pick(cid,cs);
8421 Map.DoSetComboCommand(pos, cid, cs);
8422 }
8423 }
8424 }
8425 }
8426 Map.FinishListCommand();
8427
8428 refresh(rMAP);
8429 }
8430
8431 static void draw_block(ComboPosition start, int32_t w, int32_t h)
8432 {
8433 int32_t cid = Combo;
8434 int8_t cs = CSet;
8435 if(draw_mode == dm_cpool)
8436 {
8437 combo_pool const& pool = combo_pools[combo_pool_pos];
8438 if(!pool.pick(cid,cs)) return;
8439 }
8440
8441 mapscr* scr = Map.Scr(start, CurrentLayer);
8442 if (!scr) return;
8443
8444 mark_save_dirty();
8445 Map.StartListCommand();
8446 for (int32_t y=0; y < h && y < 11*Map.getViewSize(); y++)
8447 for (int32_t x=0; x < w && x < 16*Map.getViewSize(); x++)
8448 {
8449 Map.DoSetComboCommand(start + ComboPosition{x, y}, cid+(y*4)+x, cs);
8450 }
8451
8452 Map.FinishListCommand();
8453 refresh(rMAP+rSCRMAP);
8454 }
8455
8456 static std::vector<ComboPosition> flood_filler(ComboPosition start_pos, bool allow_diagonal, std::function<bool(ComboPosition)> check)
8457 {
8458 std::vector<ComboPosition> seen, queue;
8459
8460 queue.push_back(start_pos);
8461 while (!queue.empty())
8462 {
8463 ComboPosition pos = queue.back();
8464 queue.pop_back();
8465 seen.push_back(pos);
8466
8467 ComboPosition pos2;
8468 #define FLOOD_FILLER_CHECK(dx, dy)\
8469 pos2 = pos + ComboPosition{dx, dy};\
8470 if (std::find(seen.begin(), seen.end(), pos2) == seen.end() && check(pos2))\
8471 queue.push_back(pos2);
8472
8473 FLOOD_FILLER_CHECK(0, 1);
8474 FLOOD_FILLER_CHECK(0, -1);
8475 FLOOD_FILLER_CHECK(1, 0);
8476 FLOOD_FILLER_CHECK(-1, 0);
8477
8478 if (allow_diagonal)
8479 {
8480 FLOOD_FILLER_CHECK(1, 1);
8481 FLOOD_FILLER_CHECK(1, -1);
8482 FLOOD_FILLER_CHECK(-1, 1);
8483 FLOOD_FILLER_CHECK(-1, -1);
8484 }
8485
8486 #undef FLOOD_FILLER_CHECK
8487 }
8488
8489 return seen;
8490 }
8491
8492 static void fill(int32_t targetcombo, int32_t targetcset, ComboPosition start_pos, bool allow_diagonal, bool only_cset)
8493 {
8494 bool rclick = gui_mouse_b() & 2;
8495 bool ignored_combo = false;
8496
8497 mapscr* scr = Map.ScrMakeValid(start_pos, CurrentLayer);
8498 if (!scr)
8499 return;
8500
8501 int num_combos_width = 16 * Map.getViewSize();
8502 int num_combos_height = 11 * Map.getViewSize();
8503
8504 auto combo_positions = flood_filler(start_pos, allow_diagonal, [&](ComboPosition pos){
8505 if (pos.x < 0 || pos.y < 0 || pos.x >= num_combos_width || pos.y >= num_combos_height)
8506 return false;
8507
8508 mapscr* scr = Map.Scr(pos, CurrentLayer);
8509 if (!scr || !scr->is_valid())
8510 return false;
8511
8512 int cid = scr->data[pos.truncate()];
8513 int cset = scr->cset[pos.truncate()];
8514
8515 if (draw_mode == dm_auto)
8516 {
8517 combo_auto const& cauto = combo_autos[combo_auto_pos];
8518
8519 ignored_combo = cauto.isIgnoredCombo(cid);
8520 if (rclick)
8521 {
8522 if (cauto.containsCombo(targetcombo))
8523 {
8524 if (!cauto.containsCombo(cid))
8525 return false;
8526 if (cauto.getType() == AUTOCOMBO_REPLACE && ignored_combo)
8527 return false;
8528 }
8529 else
8530 return false;
8531 }
8532 else
8533 {
8534 if (cid != targetcombo && !ignored_combo)
8535 return false;
8536 if (cauto.getType() == AUTOCOMBO_REPLACE && !ignored_combo)
8537 return false;
8538 }
8539
8540 if (cset != targetcset && !ignored_combo)
8541 return false;
8542 }
8543 else
8544 {
8545 if(!only_cset)
8546 {
8547 if (cid != targetcombo)
8548 return false;
8549 }
8550
8551 if (cset != targetcset)
8552 return false;
8553 }
8554
8555 return true;
8556 });
8557
8558 for (auto& pos : combo_positions)
8559 {
8560 int32_t cid = Combo;
8561 int8_t cs = CSet;
8562
8563 if (draw_mode == dm_cpool)
8564 {
8565 combo_pool const& pool = combo_pools[combo_pool_pos];
8566 if (!pool.pick(cid, cs)) continue;
8567 }
8568 else if (draw_mode == dm_auto)
8569 {
8570 combo_auto const& cauto = combo_autos[combo_auto_pos];
8571 if (!cauto.valid())
8572 continue;
8573 if (!rclick && (cauto.containsCombo(targetcombo) && !ignored_combo))
8574 continue;
8575 if (rclick && cauto.getEraseCombo() == targetcombo)
8576 continue;
8577 }
8578
8579 if (draw_mode == dm_auto)
8580 draw_autocombo(pos, rclick);
8581 else
8582 Map.DoSetComboCommand(pos, only_cset ? -1 : cid, cs);
8583 }
8584 }
8585
8586 static void fill_flag(int32_t targetflag, ComboPosition start_pos, bool allow_diagonal)
8587 {
8588 mapscr* scr = Map.ScrMakeValid(start_pos, CurrentLayer);
8589 if (!scr)
8590 return;
8591
8592 int num_combos_width = 16 * Map.getViewSize();
8593 int num_combos_height = 11 * Map.getViewSize();
8594
8595 auto combo_positions = flood_filler(start_pos, allow_diagonal, [&](ComboPosition pos){
8596 if (pos.x < 0 || pos.y < 0 || pos.x >= num_combos_width || pos.y >= num_combos_height)
8597 return false;
8598
8599 mapscr* scr = Map.Scr(pos, CurrentLayer);
8600 if (!scr || !scr->is_valid())
8601 return false;
8602
8603 if (scr->sflag[pos.truncate()] != targetflag)
8604 return false;
8605
8606 return true;
8607 });
8608
8609 for (auto& pos : combo_positions)
8610 Map.DoSetFlagCommand(pos, Flag);
8611 }
8612
8613 static void fill2(int32_t targetcombo, int32_t targetcset, ComboPosition pos, int32_t dir, int32_t diagonal, bool only_cset)
8614 {
8615 mapscr* scr = Map.Scr(pos, CurrentLayer);
8616 if (!scr || !scr->is_valid())
8617 return;
8618
8619 int cid = scr->data[pos.truncate()];
8620 int cset = scr->cset[pos.truncate()];
8621
8622 if (!only_cset)
8623 {
8624 if (cid == targetcombo)
8625 return;
8626 }
8627
8628 if (cset == targetcset)
8629 return;
8630
8631 cid = Combo;
8632 int8_t cs = CSet;
8633 if(draw_mode == dm_cpool)
8634 {
8635 combo_pool const& pool = combo_pools[combo_pool_pos];
8636 if(!pool.pick(cid,cs)) return;
8637 }
8638
8639 Map.DoSetComboCommand(pos, only_cset ? -1 : cid, cs);
8640
8641 int num_combos_width = 16 * Map.getViewSize();
8642 int num_combos_height = 11 * Map.getViewSize();
8643
8644 if (pos.y > 0 && dir != down)
8645 fill2(targetcombo, targetcset, pos + ComboPosition{0, -1}, up, diagonal, only_cset);
8646 if (pos.y < num_combos_height-1 && dir != up)
8647 fill2(targetcombo, targetcset, pos + ComboPosition{0, 1}, down, diagonal, only_cset);
8648 if (pos.x > 0 && dir != right)
8649 fill2(targetcombo, targetcset, pos + ComboPosition{-1, 0}, left, diagonal, only_cset);
8650 if (pos.x < num_combos_width-1 && dir != left)
8651 fill2(targetcombo, targetcset, pos + ComboPosition{1, 0}, right, diagonal, only_cset);
8652
8653 if (diagonal == 1)
8654 {
8655 if (pos.y > 0 && pos.x > 0 && dir != r_down)
8656 fill2(targetcombo, targetcset, pos + ComboPosition{-1, -1}, l_up, diagonal, only_cset);
8657 if (pos.y < num_combos_height-1 && pos.x < num_combos_width-1 && dir != l_up)
8658 fill2(targetcombo, targetcset, pos + ComboPosition{1, 1}, r_down, diagonal, only_cset);
8659 if (pos.x > 0 && pos.y < num_combos_height-1 && dir != r_up)
8660 fill2(targetcombo, targetcset, pos + ComboPosition{-1, 1}, l_down, diagonal, only_cset);
8661 if (pos.x < num_combos_width-1 && pos.y > 0 && dir != l_down)
8662 fill2(targetcombo, targetcset, pos + ComboPosition{1, -1}, r_up, diagonal, only_cset);
8663 }
8664 }
8665
8666
8667 enum SnapMode
8668 {
8669 SNAP_NONE, SNAP_HALF, SNAP_WHOLE
8670 };
8671 static void snap_xy(int& x, int& y, SnapMode mode, roundType rounding, optional<int> max_x = nullopt, optional<int> max_y = nullopt)
8672 {
8673 if(mode == SNAP_NONE)
8674 {
8675 if(max_x) x = vbound(x,*max_x,0);
8676 if(max_y) y = vbound(y,*max_y,0);
8677 return;
8678 }
8679 int xoff = 0, yoff = 0;
8680 switch(rounding)
8681 {
8682 case ROUND_TO_0:
8683 rounding = ROUND_DOWN;
8684 break;
8685 case ROUND_AWAY_0:
8686 rounding = ROUND_UP;
8687 break;
8688 }
8689 int r = 0;
8690 switch(mode)
8691 {
8692 case SNAP_HALF:
8693 r = 8;
8694 break;
8695 case SNAP_WHOLE:
8696 r = 16;
8697 break;
8698 }
8699 assert(r > 0);
8700 // r must be a power of 2, for bitwise reasons
8701 switch(rounding)
8702 {
8703 case ROUND_DOWN:
8704 break;
8705 case ROUND_UP:
8706 xoff = ((x & (r-1)) ? r : 0);
8707 yoff = ((y & (r-1)) ? r : 0);
8708 break;
8709 case ROUND_NEAREST:
8710 xoff = ((x & (r-1)) >= (r/2) ? r : 0);
8711 yoff = ((y & (r-1)) >= (r/2) ? r : 0);
8712 break;
8713 }
8714 x = (x & ~(r-1)) + xoff;
8715 y = (y & ~(r-1)) + yoff;
8716 if(max_x && x >= *max_x) x = *max_x-r;
8717 else if(max_x && x < 0) x = 0;
8718 if(max_y && y >= *max_y) y = *max_y-r;
8719 else if(max_y && y < 0) y = 0;
8720 }
8721
8722 static void doxypos(byte &px2, byte &py2, int32_t color, SnapMode snap_mode,
8723 SnapMode shift_mode, bool immediately, int32_t cursoroffx,
8724 int32_t cursoroffy, int32_t iconw, int32_t iconh)
8725 {
8726 int32_t tempcb=ComboBrush;
8727 ComboBrush=0;
8728 MouseSprite::set(ZQM_POINT_BOX);
8729
8730 int viz_off_x = (active_visible_screen ? active_visible_screen->dx * 256 : 0);
8731 int viz_off_y = (active_visible_screen ? active_visible_screen->dy * 176 : 0);
8732
8733 int32_t oldpx=px2, oldpy=py2;
8734 int32_t startxint=mapscreen_x+(showedges?int32_t(16*mapscreen_single_scale):0);
8735 int32_t startyint=mapscreen_y+(showedges?int32_t(16*mapscreen_single_scale):0);
8736 showxypos_x=px2 + viz_off_x;
8737 showxypos_y=py2 + viz_off_y;
8738 showxypos_w=iconw;
8739 showxypos_h=iconh;
8740 showxypos_color=vc(color);
8741 showxypos_icon=!showxypos_dummy;
8742 bool canedit=false;
8743 bool done=false;
8744
8745 clear_tooltip();
8746
8747 while(!done && (!(gui_mouse_b()&2) || immediately))
8748 {
8749 if(!gui_mouse_b() || immediately)
8750 {
8751 canedit=true;
8752 }
8753
8754 // TODO: would be nice if these bounds were based on the individual screen.
8755 if(canedit && gui_mouse_b()==1 && isinRect(gui_mouse_x(),gui_mouse_y(),startxint,startyint,(startxint+(256*mapscreen_screenunit_scale)-1),(startyint+(176*mapscreen_screenunit_scale)-1)))
8756 {
8757 set_mouse_range(startxint,startyint,int32_t(startxint+(256*mapscreen_screenunit_scale)-1),int32_t(startyint+(176*mapscreen_screenunit_scale)-1));
8758
8759 double offx = 0, offy = 0;
8760 roundType rounding = ROUND_DOWN;
8761 if(DragCenterOfSquares)
8762 {
8763 offx -= iconw*mapscreen_single_scale/2;
8764 offy -= iconh*mapscreen_single_scale/2;
8765 rounding = ROUND_NEAREST;
8766 }
8767 int32_t x, y;
8768 do
8769 {
8770 poll_keyboard(); // re-check shift key!
8771 x=int32_t((gui_mouse_x()-startxint+offx)/mapscreen_single_scale)-cursoroffx;
8772 y=int32_t((gui_mouse_y()-startyint+offy)/mapscreen_single_scale)-cursoroffy;
8773 showxypos_cursor_icon=true;
8774 showxypos_cursor_color = showxypos_color;
8775 auto _mode = (key[KEY_LSHIFT] || key[KEY_RSHIFT]) ? shift_mode : snap_mode;
8776 showxypos_cursor_x = x-viz_off_x;
8777 showxypos_cursor_y = y-viz_off_y;
8778 snap_xy(showxypos_cursor_x, showxypos_cursor_y, _mode, rounding, 256, 176);
8779 showxypos_cursor_x += viz_off_x;
8780 showxypos_cursor_y += viz_off_y;
8781 custom_vsync();
8782 refresh(rALL | rNOCURSOR);
8783 int32_t xpos[2], ypos[2];
8784 int32_t x1,y1,x2,y2;
8785
8786 char b1[200] = {0};
8787 char b2[200] = {0};
8788 if(showxypos_dummy)
8789 strcpy(b1, "DUMMY MEASURING");
8790 else sprintf(b1, "%d %d",oldpx,oldpy);
8791 sprintf(b2, "%d %d (%d %d)",x-viz_off_x,y-viz_off_y,showxypos_cursor_x-viz_off_x,showxypos_cursor_y-viz_off_y);
8792
8793 int len[2] = {text_length(font,b1),text_length(font,b2)};
8794
8795 if(is_compact)
8796 {
8797 xpos[0] = 4;
8798 ypos[0] = layer_panel.y - 21;
8799 xpos[1] = xpos[0];
8800 ypos[1] = ypos[0]+10;
8801 }
8802 else
8803 {
8804 xpos[0] = 450;
8805 ypos[0] = 405;
8806 xpos[1] = xpos[0];
8807 ypos[1] = ypos[0]+10;
8808 }
8809
8810 x1 = xpos[0];
8811 y1 = ypos[0];
8812 x2 = xpos[0];
8813 y2 = ypos[0];
8814 for(auto q = 0; q < 2; ++q)
8815 {
8816 if(xpos[q] < x1)
8817 x1 = xpos[q];
8818 if(ypos[q] < y1)
8819 y1 = ypos[q];
8820 if(ypos[q] > y2)
8821 y2 = ypos[q];
8822 if(xpos[q] + len[q] > x2)
8823 x2 = xpos[q] + len[q];
8824 }
8825 x1 -= 4;
8826 y1 -= 2;
8827 y2 += text_height(font)+2;
8828
8829 auto minx = zc_min(xpos[0],xpos[1]);
8830 auto miny = zc_min(ypos[0],ypos[1]);
8831 rectfill(screen,x1,y1,x2,y2,vc(0));
8832 textprintf_ex(screen,font,xpos[0],ypos[0],vc(15),vc(0),"%s",b1);
8833 textprintf_ex(screen,font,xpos[1],ypos[1],vc(15),vc(0),"%s",b2);
8834 update_hw_screen();
8835 }
8836 while(gui_mouse_b()==1);
8837
8838 if(gui_mouse_b()==0)
8839 {
8840 auto _mode = (key[KEY_LSHIFT] || key[KEY_RSHIFT]) ? shift_mode : snap_mode;
8841 int x2 = vbound(x-viz_off_x,0,255);
8842 int y2 = vbound(y-viz_off_y,0,175);
8843 snap_xy(x2, y2, _mode, rounding, 256, 176);
8844 px2=byte(x2);
8845 py2=byte(y2);
8846 }
8847
8848 set_mouse_range(0,0,zq_screen_w-1,zq_screen_h-1);
8849 done=true;
8850 }
8851
8852 if(keypressed())
8853 {
8854 switch(readkey()>>8)
8855 {
8856 case KEY_ESC:
8857 case KEY_ENTER:
8858 goto finished;
8859 }
8860 }
8861
8862 custom_vsync();
8863 refresh(rALL | rNOCURSOR);
8864 }
8865
8866 finished:
8867 MouseSprite::set(ZQM_NORMAL);
8868 refresh(rMAP+rMENU);
8869
8870 while(gui_mouse_b())
8871 {
8872 /* do nothing */
8873 rest(1);
8874 }
8875
8876 showxypos_x=-1000;
8877 showxypos_y=-1000;
8878 showxypos_color=-1000;
8879 showxypos_ffc=-1000;
8880 showxypos_icon=false;
8881 showxypos_cursor_x=-1000;
8882 showxypos_cursor_y=-1000;
8883 showxypos_cursor_icon=false;
8884 showxypos_cursor_color=-1000;
8885 showxypos_dummy=false;
8886
8887 if(px2!=oldpx||py2!=oldpy)
8888 {
8889 mark_save_dirty();
8890 }
8891
8892 ComboBrush=tempcb;
8893 }
8894 static void doxypos(byte &px2,byte &py2,int32_t color,SnapMode snap_mode, optional<SnapMode> shift_mode = nullopt)
8895 {
8896 doxypos(px2,py2,color,snap_mode,shift_mode ? *shift_mode : snap_mode,false,0,0,16,16);
8897 }
8898
8899 bool placing_flags = false;
8900 void doflags()
8901 {
8902 placing_flags = true;
8903 int of=Flags;
8904 Flags=cFLAGS;
8905 refresh(rMAP | rNOCURSOR);
8906
8907 bool canedit=false;
8908 bool didShift = false;
8909 int tFlag = Flag;
8910 while(!(gui_mouse_b()&2) && !handle_close_btn_quit())
8911 {
8912 int x=gui_mouse_x();
8913 int y=gui_mouse_y();
8914 double startx=mapscreen_x+(showedges?(16*mapscreen_single_scale):0);
8915 double starty=mapscreen_y+(showedges?(16*mapscreen_single_scale):0);
8916 int startxint=mapscreen_x+(showedges?int(16*mapscreen_single_scale):0);
8917 int startyint=mapscreen_y+(showedges?int(16*mapscreen_single_scale):0);
8918 int cx=(x-startxint)/int(16*mapscreen_single_scale);
8919 int cy=(y-startyint)/int(16*mapscreen_single_scale);
8920 ComboPosition combo_pos = {cx, cy};
8921 int c = combo_pos.truncate();
8922
8923 if(!gui_mouse_b())
8924 canedit=true;
8925 bool shift = key[KEY_LSHIFT] || key[KEY_RSHIFT];
8926
8927 if(canedit && gui_mouse_b()==1 && isinRect(x,y,startxint,startyint,int(startx+(256*mapscreen_screenunit_scale)-1),int(starty+(176*mapscreen_screenunit_scale)-1)))
8928 {
8929 mapscr* cur_scr = Map.Scr(combo_pos, CurrentLayer);
8930 if (!cur_scr) continue;
8931
8932 Map.setCurrScr(Map.getScreenForPosition(combo_pos));
8933
8934 if(key[KEY_ALT]||key[KEY_ALTGR])
8935 Flag = cur_scr->sflag[c];
8936 else
8937 {
8938 mark_save_dirty();
8939 int tflag = Flag;
8940 if(shift)
8941 Flag = mfNONE;
8942 if(CurrentLayer!=0)
8943 {
8944 // Notify if they are using a flag that doesn't work on this layer.
8945 if(!skipLayerWarning && ((Flag >= mfTRAP_H && Flag < mfPUSHD) || (Flag == mfFAIRY) || (Flag == mfMAGICFAIRY)
8946 || (Flag == mfALLFAIRY) || (Flag == mfRAFT) || (Flag == mfRAFT_BRANCH)
8947 || (Flag == mfDIVE_ITEM) || (Flag == mfARMOS_SECRET) || (Flag == mfNOENEMY)
8948 || (Flag == mfZELDA)))
8949 {
8950 InfoDialog("Notice","You are currently working on layer "
8951 +to_string(CurrentLayer)
8952 +". This combo flag does not function on layers above '0'.").show();
8953 }
8954 if(!skipLayerWarning && CurrentLayer > 2 &&
8955 ((Flag == mfBLOCKHOLE) || (Flag >= mfPUSHD && Flag < mfNOBLOCKS)
8956 || (Flag == mfPUSHUD) || (Flag == mfPUSH4)))
8957 {
8958 InfoDialog("Notice","You are currently working on layer "
8959 +to_string(CurrentLayer)
8960 +". This combo flag does not function on layers above '2'.").show();
8961 }
8962 }
8963 if(CHECK_CTRL_CMD)
8964 {
8965 switch(fill_type)
8966 {
8967 case 0:
8968 flood_flag();
8969 break;
8970
8971 case 1:
8972 case 3:
8973 fill_4_flag();
8974 break;
8975
8976 case 2:
8977 case 4:
8978 fill_8_flag();
8979 break;
8980 }
8981 }
8982 else
8983 {
8984 Map.DoSetFlagCommand(combo_pos, Flag);
8985 }
8986 Flag = tflag;
8987 }
8988 }
8989
8990 if(mouse_z)
8991 {
8992 for(int i=0; i<abs(mouse_z); ++i)
8993 {
8994 if(mouse_z>0)
8995 onIncreaseFlag();
8996 else
8997 onDecreaseFlag();
8998 }
8999
9000 position_mouse_z(0);
9001 }
9002
9003 if(keypressed())
9004 {
9005 int k = readkey();
9006 switch(k>>8)
9007 {
9008 case KEY_ESC:
9009 case KEY_ENTER:
9010 goto finished;
9011 }
9012 object_message(dialogs+1, MSG_XCHAR, k);
9013 Flags=cFLAGS;
9014 }
9015
9016 MouseSprite::set(ZQM_FLAG_0+(shift?0:Flag%16));
9017
9018 refresh(rALL | rCLEAR | rNOCURSOR);
9019 custom_vsync();
9020 }
9021
9022 finished:
9023 Flags=of;
9024 placing_flags = false;
9025 MouseSprite::set(ZQM_NORMAL);
9026 refresh(rMAP+rMENU);
9027
9028 while(gui_mouse_b())
9029 {
9030 /* do nothing */
9031 rest(1);
9032 }
9033 }
9034
9035 // Drag FFCs around
9036 static void moveffc(int i, int cx, int cy)
9037 {
9038 mapscr* scr = active_visible_screen->scr;
9039 int screen = active_visible_screen->screen;
9040
9041 int32_t ffx = vbound(scr->ffcs[i].x.getFloor(),0,240);
9042 int32_t ffy = vbound(scr->ffcs[i].y.getFloor(),0,160);
9043 int32_t offx = ffx, offy = ffy;
9044 showxypos_ffc = i;
9045 doxypos((byte&)ffx,(byte&)ffy,15,SNAP_HALF,SNAP_NONE,true,0,0,(scr->ffTileWidth(i)*16),(scr->ffTileHeight(i)*16));
9046 if(ffx > 240) ffx = 240;
9047 if(ffy > 160) ffy = 160;
9048 if((ffx != offx) || (ffy != offy))
9049 {
9050 auto set_ffc_data = set_ffc_command::create_data(scr->ffcs[i]);
9051 set_ffc_data.x = ffx;
9052 set_ffc_data.y = ffy;
9053 Map.DoSetFFCCommand(Map.getCurrMap(), screen, i, set_ffc_data);
9054 mark_save_dirty();
9055 }
9056 }
9057
9058 void set_brush_width(int32_t width);
9059 void set_brush_height(int32_t height);
9060
9061 int32_t set_brush_width_1()
9062 {
9063 set_brush_width(1);
9064 return D_O_K;
9065 }
9066 int32_t set_brush_width_2()
9067 {
9068 set_brush_width(2);
9069 return D_O_K;
9070 }
9071 int32_t set_brush_width_3()
9072 {
9073 set_brush_width(3);
9074 return D_O_K;
9075 }
9076 int32_t set_brush_width_4()
9077 {
9078 set_brush_width(4);
9079 return D_O_K;
9080 }
9081 int32_t set_brush_width_5()
9082 {
9083 set_brush_width(5);
9084 return D_O_K;
9085 }
9086 int32_t set_brush_width_6()
9087 {
9088 set_brush_width(6);
9089 return D_O_K;
9090 }
9091 int32_t set_brush_width_7()
9092 {
9093 set_brush_width(7);
9094 return D_O_K;
9095 }
9096 int32_t set_brush_width_8()
9097 {
9098 set_brush_width(8);
9099 return D_O_K;
9100 }
9101 int32_t set_brush_width_9()
9102 {
9103 set_brush_width(9);
9104 return D_O_K;
9105 }
9106 int32_t set_brush_width_10()
9107 {
9108 set_brush_width(10);
9109 return D_O_K;
9110 }
9111 int32_t set_brush_width_11()
9112 {
9113 set_brush_width(11);
9114 return D_O_K;
9115 }
9116 int32_t set_brush_width_12()
9117 {
9118 set_brush_width(12);
9119 return D_O_K;
9120 }
9121 int32_t set_brush_width_13()
9122 {
9123 set_brush_width(13);
9124 return D_O_K;
9125 }
9126 int32_t set_brush_width_14()
9127 {
9128 set_brush_width(14);
9129 return D_O_K;
9130 }
9131 int32_t set_brush_width_15()
9132 {
9133 set_brush_width(15);
9134 return D_O_K;
9135 }
9136 int32_t set_brush_width_16()
9137 {
9138 set_brush_width(16);
9139 return D_O_K;
9140 }
9141
9142 int32_t set_brush_height_1()
9143 {
9144 set_brush_height(1);
9145 return D_O_K;
9146 }
9147 int32_t set_brush_height_2()
9148 {
9149 set_brush_height(2);
9150 return D_O_K;
9151 }
9152 int32_t set_brush_height_3()
9153 {
9154 set_brush_height(3);
9155 return D_O_K;
9156 }
9157 int32_t set_brush_height_4()
9158 {
9159 set_brush_height(4);
9160 return D_O_K;
9161 }
9162 int32_t set_brush_height_5()
9163 {
9164 set_brush_height(5);
9165 return D_O_K;
9166 }
9167 int32_t set_brush_height_6()
9168 {
9169 set_brush_height(6);
9170 return D_O_K;
9171 }
9172 int32_t set_brush_height_7()
9173 {
9174 set_brush_height(7);
9175 return D_O_K;
9176 }
9177 int32_t set_brush_height_8()
9178 {
9179 set_brush_height(8);
9180 return D_O_K;
9181 }
9182 int32_t set_brush_height_9()
9183 {
9184 set_brush_height(9);
9185 return D_O_K;
9186 }
9187 int32_t set_brush_height_10()
9188 {
9189 set_brush_height(10);
9190 return D_O_K;
9191 }
9192 int32_t set_brush_height_11()
9193 {
9194 set_brush_height(11);
9195 return D_O_K;
9196 }
9197
9198
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu brush_width_menu
9199 204 {
9200
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "1", set_brush_width_1 },
9201
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "2", set_brush_width_2 },
9202
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "3", set_brush_width_3 },
9203
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "4", set_brush_width_4 },
9204
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "5", set_brush_width_5 },
9205
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "6", set_brush_width_6 },
9206
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "7", set_brush_width_7 },
9207
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "8", set_brush_width_8 },
9208
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "9", set_brush_width_9 },
9209
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "10", set_brush_width_10 },
9210
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "11", set_brush_width_11 },
9211
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "12", set_brush_width_12 },
9212
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "13", set_brush_width_13 },
9213
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "14", set_brush_width_14 },
9214
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "15", set_brush_width_15 },
9215
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "16", set_brush_width_16 },
9216 };
9217
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu brush_height_menu
9218 144 {
9219
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "1", set_brush_height_1 },
9220
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "2", set_brush_height_2 },
9221
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "3", set_brush_height_3 },
9222
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "4", set_brush_height_4 },
9223
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "5", set_brush_height_5 },
9224
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "6", set_brush_height_6 },
9225
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "7", set_brush_height_7 },
9226
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "8", set_brush_height_8 },
9227
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "9", set_brush_height_9 },
9228
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "10", set_brush_height_10 },
9229
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "11", set_brush_height_11 },
9230 };
9231
9232 int toggle_autobrush();
9233 int toggle_combobrush();
9234 int toggle_floatbrush();
9235 enum
9236 {
9237 MENUID_BRUSH_AUTOBRUSH,
9238 MENUID_BRUSH_WIDTH,
9239 MENUID_BRUSH_HEIGHT,
9240 MENUID_BRUSH_COMBOBRUSH,
9241 MENUID_BRUSH_FLOATBRUSH,
9242 };
9243
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu brush_menu
9244 72 {
9245
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "AutoBrush", toggle_autobrush, MENUID_BRUSH_AUTOBRUSH },
9246
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Brush Width ", &brush_width_menu, MENUID_BRUSH_WIDTH },
9247
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Brush Height ", &brush_height_menu, MENUID_BRUSH_HEIGHT },
9248
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "ComboBrush", toggle_combobrush, MENUID_BRUSH_COMBOBRUSH },
9249
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "FloatBrush", toggle_floatbrush, MENUID_BRUSH_FLOATBRUSH },
9250 };
9251 int toggle_autobrush()
9252 {
9253 AutoBrush = AutoBrush ? 0 : 1;
9254 BrushWidth = BrushHeight = 1;
9255 brush_menu.select_uid(MENUID_BRUSH_AUTOBRUSH, AutoBrush);
9256 brush_menu.disable_uid(MENUID_BRUSH_WIDTH, AutoBrush);
9257 brush_menu.disable_uid(MENUID_BRUSH_HEIGHT, AutoBrush);
9258 zc_set_config("zquest","autobrush",AutoBrush);
9259 return D_O_K;
9260 }
9261 int toggle_combobrush()
9262 {
9263 ComboBrush = ComboBrush ? 0 : 1;
9264 brush_menu.select_uid(MENUID_BRUSH_COMBOBRUSH, ComboBrush);
9265 zc_set_config("zquest","combo_brush",ComboBrush);
9266 return D_O_K;
9267 }
9268 int toggle_floatbrush()
9269 {
9270 FloatBrush = FloatBrush ? 0 : 1;
9271 brush_menu.select_uid(MENUID_BRUSH_FLOATBRUSH, FloatBrush);
9272 zc_set_config("zquest","float_brush",FloatBrush);
9273 return D_O_K;
9274 }
9275
9276 int32_t set_flood();
9277 int32_t set_fill_4();
9278 int32_t set_fill_8();
9279 int32_t set_fill2_4();
9280 int32_t set_fill2_8();
9281
9282 // Sets every combo.
9283 void flood()
9284 {
9285 ComboPosition pos = get_mapscreen_mouse_combo_pos();
9286 mapscr* scr = Map.ScrMakeValid(pos, CurrentLayer);
9287 if (!scr || !scr->is_valid())
9288 return;
9289
9290 mark_save_dirty();
9291
9292 bool include_combos = !(key[KEY_LSHIFT]||key[KEY_RSHIFT]);
9293
9294 int num_combos_width = 16 * Map.getViewSize();
9295 int num_combos_height = 11 * Map.getViewSize();
9296
9297 Map.StartListCommand();
9298 for (int x = 0; x < num_combos_width; x++)
9299 {
9300 for (int y = 0; y < num_combos_height; y++)
9301 {
9302 ComboPosition pos = {x, y};
9303 mapscr* scr = Map.Scr(pos, CurrentLayer);
9304 if (!scr || !scr->is_valid())
9305 continue;
9306
9307 if (draw_mode == dm_auto)
9308 draw_autocombo(pos, gui_mouse_b() & 2);
9309 else
9310 Map.DoSetComboCommand(pos, include_combos ? Combo : -1, CSet);
9311 }
9312 }
9313 Map.FinishListCommand();
9314
9315 refresh(rMAP+rSCRMAP);
9316 }
9317 void flood_flag()
9318 {
9319 ComboPosition pos = get_mapscreen_mouse_combo_pos();
9320 mapscr* scr = Map.ScrMakeValid(pos, CurrentLayer);
9321 if (!scr || !scr->is_valid())
9322 return;
9323
9324 mark_save_dirty();
9325
9326 int num_combos_width = 16 * Map.getViewSize();
9327 int num_combos_height = 11 * Map.getViewSize();
9328
9329 Map.StartListCommand();
9330 for (int x = 0; x < num_combos_width; x++)
9331 {
9332 for (int y = 0; y < num_combos_height; y++)
9333 {
9334 ComboPosition pos = {x, y};
9335 mapscr* scr = Map.Scr(pos, CurrentLayer);
9336 if (!scr || !scr->is_valid())
9337 continue;
9338
9339 Map.DoSetFlagCommand(pos, Flag);
9340 }
9341 }
9342 Map.FinishListCommand();
9343
9344 refresh(rMAP+rSCRMAP);
9345 }
9346
9347 void fill_4()
9348 {
9349 ComboPosition pos = get_mapscreen_mouse_combo_pos();
9350 mapscr* scr = Map.ScrMakeValid(pos, CurrentLayer);
9351 if (!scr)
9352 return;
9353
9354 int c = pos.truncate();
9355 if (draw_mode == dm_cpool || draw_mode == dm_auto
9356 || (scr->cset[c]!=CSet || (scr->data[c]!=Combo && !(key[KEY_LSHIFT]||key[KEY_RSHIFT]))))
9357 {
9358 mark_save_dirty();
9359
9360 Map.StartListCommand();
9361 if (draw_mode == dm_auto && (combo_autos[combo_auto_pos].getType() == AUTOCOMBO_FENCE ||
9362 combo_autos[combo_auto_pos].getType() == AUTOCOMBO_Z4))
9363 {
9364 draw_autocombo_command(pos);
9365 }
9366 else
9367 {
9368 bool allow_diagonal = false;
9369 fill(scr->data[c], scr->cset[c], pos, allow_diagonal, (key[KEY_LSHIFT] || key[KEY_RSHIFT]));
9370 }
9371 Map.FinishListCommand();
9372 refresh(rMAP+rSCRMAP);
9373 }
9374 }
9375 void fill_4_flag()
9376 {
9377 ComboPosition pos = get_mapscreen_mouse_combo_pos();
9378 mapscr* scr = Map.ScrMakeValid(pos, CurrentLayer);
9379 if (!scr)
9380 return;
9381
9382 int flag = scr->sflag[pos.truncate()];
9383 if (flag != Flag)
9384 {
9385 mark_save_dirty();
9386
9387 Map.StartListCommand();
9388 bool allow_diagonal = false;
9389 fill_flag(flag, pos, allow_diagonal);
9390 Map.FinishListCommand();
9391 refresh(rMAP+rSCRMAP);
9392 }
9393 }
9394 void fill_8()
9395 {
9396 ComboPosition pos = get_mapscreen_mouse_combo_pos();
9397 mapscr* scr = Map.ScrMakeValid(pos, CurrentLayer);
9398 if (!scr)
9399 return;
9400
9401 int c = pos.truncate();
9402 if (draw_mode == dm_cpool || draw_mode == dm_auto
9403 || (scr->cset[c] != CSet ||
9404 (scr->data[c] != Combo &&
9405 !(key[KEY_LSHIFT]||key[KEY_RSHIFT]))))
9406 {
9407 mark_save_dirty();
9408
9409 Map.StartListCommand();
9410 bool allow_diagonal = true;
9411 fill(scr->data[c], scr->cset[c], pos, allow_diagonal, (key[KEY_LSHIFT]||key[KEY_RSHIFT]));
9412 Map.FinishListCommand();
9413
9414 refresh(rMAP+rSCRMAP);
9415 }
9416 }
9417 void fill_8_flag()
9418 {
9419 ComboPosition pos = get_mapscreen_mouse_combo_pos();
9420 mapscr* scr = Map.ScrMakeValid(pos, CurrentLayer);
9421 if (!scr)
9422 return;
9423
9424 int flag = scr->sflag[pos.truncate()];
9425 if (flag != Flag)
9426 {
9427 mark_save_dirty();
9428
9429 Map.StartListCommand();
9430 bool allow_diagonal = true;
9431 fill_flag(flag, pos, allow_diagonal);
9432 Map.FinishListCommand();
9433 refresh(rMAP+rSCRMAP);
9434 }
9435 }
9436
9437 void fill2_4()
9438 {
9439 ComboPosition pos = get_mapscreen_mouse_combo_pos();
9440 mapscr* scr = Map.ScrMakeValid(pos, CurrentLayer);
9441 if (!scr)
9442 return;
9443
9444 mark_save_dirty();
9445
9446 Map.StartListCommand();
9447 fill2(Combo, CSet, pos, 255, 0, (key[KEY_LSHIFT]||key[KEY_RSHIFT]));
9448 Map.FinishListCommand();
9449 refresh(rMAP+rSCRMAP);
9450 }
9451
9452 void fill2_8()
9453 {
9454 ComboPosition pos = get_mapscreen_mouse_combo_pos();
9455 mapscr* scr = Map.ScrMakeValid(pos, CurrentLayer);
9456 if (!scr)
9457 return;
9458
9459 mark_save_dirty();
9460
9461 Map.StartListCommand();
9462 fill2(Combo, CSet, pos, 255, 1, (key[KEY_LSHIFT]||key[KEY_RSHIFT]));
9463 Map.FinishListCommand();
9464
9465 refresh(rMAP+rSCRMAP);
9466 }
9467
9468
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu fill_menu
9469 72 {
9470
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Flood", set_flood, 0 },
9471
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Fill (4-way)", set_fill_4, 1 },
9472
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Fill (8-way)", set_fill_8, 2 },
9473
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Fill2 (4-way)", set_fill2_4, 3 },
9474
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Fill2 (8-way)", set_fill2_8, 4 },
9475 };
9476 void set_filltype(int ty)
9477 {
9478 fill_type = ty;
9479 fill_menu.select_only_uid(ty);
9480 }
9481
9482 int32_t set_flood()
9483 {
9484 set_filltype(0);
9485 return D_O_K;
9486 }
9487
9488 int32_t set_fill_4()
9489 {
9490 set_filltype(1);
9491 return D_O_K;
9492 }
9493
9494 int32_t set_fill_8()
9495 {
9496 set_filltype(2);
9497 return D_O_K;
9498 }
9499
9500 int32_t set_fill2_4()
9501 {
9502 set_filltype(3);
9503 return D_O_K;
9504 }
9505
9506 int32_t set_fill2_8()
9507 {
9508 set_filltype(4);
9509 return D_O_K;
9510 }
9511
9512 int32_t draw_block_1_2()
9513 {
9514 draw_block(mouse_combo_pos,1,2);
9515 return D_O_K;
9516 }
9517
9518 int32_t draw_block_2_1()
9519 {
9520 draw_block(mouse_combo_pos,2,1);
9521 return D_O_K;
9522 }
9523
9524 int32_t draw_block_2_2()
9525 {
9526 draw_block(mouse_combo_pos,2,2);
9527 return D_O_K;
9528 }
9529
9530 int32_t draw_block_2_3()
9531 {
9532 draw_block(mouse_combo_pos,2,3);
9533 return D_O_K;
9534 }
9535
9536 int32_t draw_block_3_2()
9537 {
9538 draw_block(mouse_combo_pos,3,2);
9539 return D_O_K;
9540 }
9541
9542 int32_t draw_block_3_3()
9543 {
9544 draw_block(mouse_combo_pos,3,3);
9545 return D_O_K;
9546 }
9547
9548 int32_t draw_block_4_2()
9549 {
9550 draw_block(mouse_combo_pos,4,2);
9551 return D_O_K;
9552 }
9553
9554 int32_t draw_block_4_4()
9555 {
9556 draw_block(mouse_combo_pos,4,4);
9557 return D_O_K;
9558 }
9559
9560
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu draw_block_menu
9561 108 {
9562
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "1x2", draw_block_1_2 },
9563
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "2x1", draw_block_2_1 },
9564
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "2x2", draw_block_2_2 },
9565
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "2x3", draw_block_2_3 },
9566
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "3x2", draw_block_3_2 },
9567
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "3x3", draw_block_3_3 },
9568
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "4x2", draw_block_4_2 },
9569
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "4x4", draw_block_4_4 },
9570 };
9571
9572
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu paste_screen_menu
9573 60 {
9574
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Paste", onPaste },
9575
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Paste All", onPasteAll },
9576
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Paste to All", onPasteToAll },
9577
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Paste All to All", onPasteAllToAll },
9578 };
9579
9580 int32_t scrollto_cmb(int32_t cid)
9581 {
9582 auto& sqr = combolist[current_combolist];
9583 int32_t res = vbound(cid-(sqr.w*sqr.h/2),0,MAXCOMBOS-(sqr.w*sqr.h));
9584 res -= res%sqr.w;
9585 return res;
9586 }
9587 int32_t scrollto_alias(int32_t alid)
9588 {
9589 auto& sqr = comboaliaslist[current_comboalist];
9590 int32_t res = vbound(alid-(sqr.w*sqr.h/2),0,MAXCOMBOALIASES-(sqr.w*sqr.h));
9591 res -= res%sqr.w;
9592 return res;
9593 }
9594
9595 int32_t scrollto_cpool(int32_t cpid)
9596 {
9597 auto& sqr = comboaliaslist[current_cpoollist];
9598 int32_t res = vbound(cpid-(sqr.w*sqr.h/2),0,MAXCOMBOPOOLS-(sqr.w*sqr.h));
9599 res -= res%sqr.w;
9600 return res;
9601 }
9602
9603 int32_t scrollto_cauto(int32_t caid)
9604 {
9605 auto& sqr = comboaliaslist[current_cautolist];
9606 int32_t res = vbound(caid - (sqr.w * sqr.h / 2), 0, MAXCOMBOPOOLS - (sqr.w * sqr.h));
9607 res -= res % sqr.w;
9608 return res;
9609 }
9610
9611 void add_favorite_combo_block(int32_t favind, int32_t cid, bool force)
9612 {
9613 int32_t w = vbound(BrushWidth, 1, 4);
9614 int32_t h = vbound(BrushHeight, 1, 7);
9615 for (int32_t xi = 0; xi < w; ++xi)
9616 {
9617 for (int32_t yi = 0; yi < h; ++yi)
9618 {
9619 int32_t cx = cid % 4;
9620 int32_t cy = cid / 4;
9621 int32_t cc = (cy + yi) * 4 + cx + xi;
9622 int32_t fx = favind % FAVORITECOMBO_PER_ROW;
9623 int32_t fy = favind / FAVORITECOMBO_PER_ROW;
9624 int32_t fc = (fy + yi) * FAVORITECOMBO_PER_ROW + fx + xi + FAVORITECOMBO_PER_PAGE * FavoriteComboPage;
9625
9626 if (cx + xi < 4 && cc < MAXCOMBOS && fx + xi < FAVORITECOMBO_PER_ROW && fy + yi < FAVORITECOMBO_PER_COLUMN)
9627 {
9628 if (favorite_combos[fc] < 0 || force)
9629 {
9630 favorite_combo_modes[fc] = dm_normal;
9631 favorite_combos[fc] = cc;
9632 }
9633 }
9634 }
9635 }
9636 }
9637
9638 void onRCSelectCombo(int32_t c)
9639 {
9640 int32_t drawmap, drawscr;
9641
9642 if(CurrentLayer==0)
9643 {
9644 drawmap=Map.getCurrMap();
9645 drawscr=Map.getCurrScr();
9646 }
9647 else
9648 {
9649 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
9650 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
9651 }
9652 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
9653 if(!draw_mapscr) return;
9654
9655 Combo=draw_mapscr->data[c];
9656 if(AutoBrush)
9657 BrushWidth = BrushHeight = 1;
9658 }
9659
9660 void onRCScrollToombo(int32_t c)
9661 {
9662 int32_t drawmap, drawscr;
9663
9664 if(CurrentLayer==0)
9665 {
9666 drawmap=Map.getCurrMap();
9667 drawscr=Map.getCurrScr();
9668 }
9669 else
9670 {
9671 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
9672 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
9673 }
9674 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
9675 if(!draw_mapscr) return;
9676
9677 auto& sqr = combolist[current_combolist];
9678 First[current_combolist]=scrollto_cmb(draw_mapscr->data[c]);
9679 }
9680
9681 enum
9682 {
9683 MENUID_RCSCREEN_PASTE,
9684 MENUID_RCSCREEN_ADVPASTE,
9685 MENUID_RCSCREEN_SPECPASTE,
9686 };
9687
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu rc_menu_screen
9688 60 {
9689
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Copy Screen", onCopy },
9690
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Paste Screen", &paste_screen_menu, MENUID_RCSCREEN_PASTE },
9691
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "...Advanced Paste", &paste_menu, MENUID_RCSCREEN_ADVPASTE },
9692
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "...Special Paste", &paste_item_menu, MENUID_RCSCREEN_SPECPASTE },
9693 };
9694
9695 void call_options_dlg();
9696 int32_t onOptions()
9697 {
9698 call_options_dlg();
9699 brush_menu.select_uid(MENUID_BRUSH_AUTOBRUSH, AutoBrush);
9700 brush_menu.disable_uid(MENUID_BRUSH_WIDTH, AutoBrush);
9701 brush_menu.disable_uid(MENUID_BRUSH_HEIGHT, AutoBrush);
9702 brush_menu.select_uid(MENUID_BRUSH_FLOATBRUSH, FloatBrush);
9703 brush_menu.select_uid(MENUID_BRUSH_COMBOBRUSH, ComboBrush);
9704 return D_O_K;
9705 }
9706
9707 void follow_twarp(int warpindex)
9708 {
9709 if(warpindex >= 4)
9710 {
9711 InfoDialog("Random Tile Warp",
9712 "This is a random tile warp combo, so it chooses"
9713 " randomly between the screen's four Tile Warps.").show();
9714 warpindex=zc_oldrand()&3;
9715 }
9716
9717 int32_t tm = Map.getCurrMap();
9718 int32_t ts = Map.getCurrScr();
9719 int32_t wt = Map.CurrScr()->tilewarptype[warpindex];
9720
9721 if(wt==wtCAVE || wt==wtNOWARP)
9722 {
9723 char buf[56];
9724 InfoDialog(warptype_string[wt],fmt::format("This screen's Tile Warp {} is set to {}, so it doesn't lead to another screen.",'A'+warpindex,warptype_string[wt]));
9725 return;
9726 }
9727
9728 Map.dowarp(0,warpindex);
9729
9730 if(ts!=Map.getCurrScr() || tm!=Map.getCurrMap())
9731 {
9732 FlashWarpSquare = (TheMaps[tm*MAPSCRS+ts].warpreturnc>>(warpindex*2))&3;
9733 FlashWarpClk = 32;
9734 }
9735 }
9736 void edit_twarp(int warpindex)
9737 {
9738 if(warpindex>=4)
9739 {
9740 InfoDialog("Random Tile Warp",
9741 "This is a random tile warp combo, so it chooses"
9742 " randomly between the screen's four Tile Warps.").show();
9743 warpindex=zc_oldrand()&3;
9744 }
9745
9746 if(warpindex > -1 && warpindex < 4)
9747 onTileWarpIndex(warpindex);
9748 }
9749
9750 int toggle_linked_scrolling()
9751 {
9752 LinkedScroll = LinkedScroll ? 0 : 1;
9753 zc_set_config("zquest","linked_comboscroll",LinkedScroll);
9754 return D_O_K;
9755 }
9756 void on_scroll_cpane()
9757 {
9758 switch (draw_mode)
9759 {
9760 case dm_alias:
9761 combo_alistpos[current_comboalist] = scrollto_alias(combo_apos);
9762 break;
9763 case dm_cpool:
9764 combo_pool_listpos[current_cpoollist] = scrollto_cpool(combo_pool_pos);
9765 break;
9766 case dm_auto:
9767 combo_auto_listpos[current_cautolist] = scrollto_cauto(combo_auto_pos);
9768 break;
9769 default:
9770 First[current_combolist] = scrollto_cmb(Combo);
9771 break;
9772 }
9773 }
9774 void on_edit_cpane()
9775 {
9776 switch (draw_mode)
9777 {
9778 case dm_alias:
9779 onEditComboAlias();
9780 break;
9781 case dm_cpool:
9782 onEditComboPool();
9783 break;
9784 case dm_auto:
9785 onEditAutoCombo();
9786 break;
9787 default:
9788 reset_combo_animations();
9789 reset_combo_animations2();
9790 edit_combo(Combo, true, CSet);
9791 setup_combo_animations();
9792 setup_combo_animations2();
9793 break;
9794 }
9795 }
9796 void open_combo_pages(optional<int> cid)
9797 {
9798 int cmb_id = cid ? *cid : 0;
9799 combo_screen(cmb_id >> 8, cmb_id);
9800 }
9801 void on_cpane_page()
9802 {
9803 switch(draw_mode)
9804 {
9805 case dm_normal:
9806 open_combo_pages(Combo);
9807 break;
9808 case dm_alias:
9809 call_alias_pages(combo_apos);
9810 break;
9811 case dm_auto:
9812 call_autoc_pages(combo_auto_pos);
9813 break;
9814 case dm_cpool:
9815 call_cpool_pages(combo_pool_pos);
9816 break;
9817 }
9818 }
9819 void open_cpane_tilepage()
9820 {
9821 onGotoTiles(combobuf[Combo].o_tile);
9822 }
9823 static int _clicked_fav = 0;
9824 void fav_rc_remove()
9825 {
9826 favorite_combo_modes[_clicked_fav] = dm_normal;
9827 favorite_combos[_clicked_fav] = -1;
9828 mark_save_dirty();
9829 }
9830 void popup_favorites_rc(int f, int x, int y)
9831 {
9832 _clicked_fav = f;
9833 string type;
9834 switch (draw_mode)
9835 {
9836 case dm_alias:
9837 type = "Alias";
9838 break;
9839 case dm_cpool:
9840 type = "Pool";
9841 break;
9842 case dm_auto:
9843 type = "Autocombo";
9844 break;
9845 case dm_normal:
9846 type = "Combo";
9847 break;
9848 default: return;
9849 }
9850 NewMenu rcmenu
9851 {
9852 { fmt::format("Scroll to {}", type), on_scroll_cpane },
9853 { fmt::format("Edit {}", type), on_edit_cpane },
9854 { fmt::format("Open {} Page", type), on_cpane_page },
9855 { fmt::format("Remove Fav {}", type), fav_rc_remove },
9856 };
9857 switch (draw_mode)
9858 {
9859 case dm_normal:
9860 rcmenu.add({
9861 {},
9862 { "Open Tile Page", open_cpane_tilepage },
9863 });
9864 break;
9865 }
9866 rcmenu.pop(x, y);
9867 }
9868 void popup_cpane_rc(int x, int y)
9869 {
9870 string type;
9871 switch (draw_mode)
9872 {
9873 case dm_alias:
9874 type = "Alias";
9875 break;
9876 case dm_cpool:
9877 type = "Pool";
9878 break;
9879 case dm_auto:
9880 type = "Autocombo";
9881 break;
9882 case dm_normal:
9883 type = "Combo";
9884 break;
9885 default: return;
9886 }
9887 NewMenu rcmenu;
9888 switch(draw_mode)
9889 {
9890 case dm_normal:
9891 rcmenu.add({
9892 { fmt::format("Edit {}", type), on_edit_cpane },
9893 { fmt::format("Open {} Page", type), on_cpane_page },
9894 { "Open Tile Page", open_cpane_tilepage },
9895 { "Combo Locations", onComboLocationReport },
9896 {},
9897 { "Scroll to Page...", onGotoPage },
9898 { "Linked Scrolling", toggle_linked_scrolling, nullopt, LinkedScroll ? MFL_SEL : 0 },
9899 });
9900 break;
9901 case dm_alias:
9902 case dm_cpool:
9903 case dm_auto:
9904 rcmenu.add({
9905 { fmt::format("Edit {}", type), on_edit_cpane },
9906 { fmt::format("Open {} Page", type), on_cpane_page },
9907 {},
9908 { "Scroll to Page...", onGotoPage },
9909 { "Linked Scrolling", toggle_linked_scrolling, nullopt, LinkedScroll ? MFL_SEL : 0 },
9910 });
9911 break;
9912 }
9913 rcmenu.pop(x, y);
9914 }
9915
9916 void set_brush_width(int32_t width)
9917 {
9918 BrushWidth = width;
9919 for(int q = 0; q < brush_width_menu.size(); ++q)
9920 brush_width_menu.at(q)->select(q==BrushWidth-1);
9921 refresh(rALL);
9922 }
9923
9924 void set_brush_height(int32_t height)
9925 {
9926 BrushHeight = height;
9927 for(int q = 0; q < brush_height_menu.size(); ++q)
9928 brush_height_menu.at(q)->select(q==BrushHeight-1);
9929 refresh(rALL);
9930 }
9931
9932 1 void restore_mouse()
9933 {
9934 1 ComboBrushPause=1;
9935 1 MouseSprite::set(ZQM_NORMAL);
9936 1 }
9937
9938 static int32_t comboa_cnt=0;
9939 static int32_t combop_cnt=0;
9940 static int32_t layer_cnt=0;
9941
9942 static char paste_ffc_menu_text[21];
9943 static char paste_ffc_menu_text2[21];
9944 static char follow_warp_menu_text[21];
9945 static char follow_warp_menu_text2[21];
9946
9947 static int fake_mouse_b(){return 0;}
9948 static int (*mouseb_proc)();
9949 static bool killed_mouse = false;
9950 void zq_killmouse()
9951 {
9952 if(killed_mouse) return;
9953 mouseb_proc = gui_mouse_b;
9954 gui_mouse_b = fake_mouse_b;
9955 killed_mouse = true;
9956 }
9957 void zq_restoremouse()
9958 {
9959 if(!killed_mouse) return;
9960 gui_mouse_b = mouseb_proc;
9961 killed_mouse = false;
9962 }
9963
9964
9965 void domouse()
9966 {
9967 static int mouse_down = 0;
9968 static int32_t scrolldelay = 0;
9969 auto mousexy = zc_get_mouse();
9970 auto x = mousexy.first;
9971 auto y = mousexy.second;
9972 double startx=mapscreen_x+(showedges?(16*mapscreen_single_scale):0);
9973 double starty=mapscreen_y+(showedges?(16*mapscreen_single_scale):0);
9974 int32_t startxint=mapscreen_x+(showedges?int32_t(16*mapscreen_single_scale):0);
9975 int32_t startyint=mapscreen_y+(showedges?int32_t(16*mapscreen_single_scale):0);
9976 int32_t cx=(x-startx)/(16*mapscreen_single_scale);
9977 int32_t cy=(y-starty)/(16*mapscreen_single_scale);
9978 ComboPosition combo_pos = {cx, cy};
9979
9980 if (draw_mode == dm_auto)
9981 {
9982 if (combo_pos != mouse_combo_pos)
9983 combobrushoverride = get_autocombo_floating_cid(combo_pos, false);
9984 }
9985 else
9986 combobrushoverride = -1;
9987
9988 mouse_combo_pos = combo_pos;
9989 update_combobrush();
9990
9991 ++scrolldelay;
9992
9993 bool x_on_list = false;
9994 for(auto q = 0; q < num_combo_cols; ++q)
9995 {
9996 if((x>=combolist[q].x) && (x<combolist[q].x+(combolist[q].xscale*combolist[q].w)))
9997 {
9998 x_on_list = true;
9999 break;
10000 }
10001 }
10002 if(MouseScroll && x_on_list && (key[KEY_LSHIFT] || key[KEY_RSHIFT] || (scrolldelay&3)==0))
10003 {
10004 int32_t test_list=0;
10005
10006 for(test_list=0; test_list<num_combo_cols; ++test_list)
10007 {
10008 if((x>=combolist[test_list].x) && (x<combolist[test_list].x+(combolist[test_list].xscale*combolist[test_list].w)))
10009 {
10010 break;
10011 }
10012 }
10013
10014 if(test_list<num_combo_cols)
10015 {
10016 if(y>=combolist[test_list].y-mouse_scroll_h && y<=combolist[test_list].y && First[test_list])
10017 {
10018 if((CHECK_CTRL_CMD)&&(key[KEY_ALT] || key[KEY_ALTGR]))
10019 {
10020 First[test_list]=0;
10021 }
10022 else if(CHECK_CTRL_CMD)
10023 {
10024 First[test_list]-=zc_min(First[test_list],256);
10025 }
10026 else if(key[KEY_ALT] || key[KEY_ALTGR])
10027 {
10028 First[test_list]-=zc_min(First[test_list],(combolist[test_list].w*combolist[test_list].h));
10029 }
10030 else
10031 {
10032 First[test_list]-=zc_min(First[test_list],combolist[test_list].w);
10033 }
10034 }
10035
10036 if(y>=combolist[test_list].y+(combolist[test_list].h*combolist[test_list].yscale)-1 && y<combolist[test_list].y+(combolist[test_list].h*combolist[test_list].yscale)+mouse_scroll_h-1 && First[test_list]<(MAXCOMBOS-(combolist[test_list].w*combolist[test_list].h)))
10037 {
10038 int32_t offset = combolist[test_list].w*combolist[test_list].h;
10039
10040 if((CHECK_CTRL_CMD)&&(key[KEY_ALT] || key[KEY_ALTGR]))
10041 {
10042 First[test_list]=MAXCOMBOS-offset;
10043 }
10044 else if(CHECK_CTRL_CMD)
10045 {
10046 First[test_list] = zc_min(MAXCOMBOS-offset, First[test_list]+256);
10047 }
10048 else if(key[KEY_ALT] || key[KEY_ALTGR])
10049 {
10050 First[test_list] = zc_min(MAXCOMBOS-offset, First[test_list]+ offset);
10051 }
10052 else
10053 {
10054 First[test_list] = zc_min(MAXCOMBOS - offset, First[test_list] + combolist[test_list].w);
10055 }
10056 }
10057 }
10058 }
10059
10060 // The screen for this combo_pos, layer 0. Used to access ffcs.
10061 mapscr* scr = Map.Scr(combo_pos);
10062 // The screen for this combo_pos at the CurrentLayer. Could be same as scr.
10063 mapscr* draw_mapscr = scr && CurrentLayer ? Map.Scr(combo_pos, CurrentLayer) : scr;
10064 int c = combo_pos.truncate();
10065 set_active_visible_screen(scr);
10066
10067 //-------------
10068 //tooltip stuff
10069 //-------------
10070 if (active_visible_screen && isinRect(x,y,startxint,startyint,startxint+(256*mapscreen_screenunit_scale)-1,startyint+(176*mapscreen_screenunit_scale)-1))
10071 {
10072 static int mapscr_tooltip_id = ttip_register_id();
10073 bool did_ffttip = false;
10074 int num_ffcs = scr->numFFC();
10075 for(int32_t i=num_ffcs-1; i>=0; i--)
10076 if(scr->ffcs[i].data !=0 && (scr->ffcs[i].layer >= CurrentLayer || (!CurrentLayer && scr->ffcs[i].layer < 0) || (scr->ffcs[i].flags&ffc_overlay)))
10077 {
10078 int32_t ffx = scr->ffcs[i].x.getFloor() + active_visible_screen->dx * 256;
10079 int32_t ffy = scr->ffcs[i].y.getFloor() + active_visible_screen->dy * 176;
10080 int32_t ffw = scr->ffTileWidth(i)*16;
10081 int32_t ffh = scr->ffTileHeight(i)*16;
10082 int32_t cx2 = (x-startxint)/mapscreen_single_scale;
10083 int32_t cy2 = (y-startyint)/mapscreen_single_scale;
10084
10085 if(cx2 >= ffx && cx2 < ffx+ffw && cy2 >= ffy && cy2 < ffy+ffh)
10086 {
10087 // FFC tooltip
10088 if(tooltip_current_ffc != i)
10089 {
10090 clear_tooltip();
10091 }
10092
10093 tooltip_current_ffc = i;
10094 char msg[1024] = {0};
10095 auto& ff = scr->ffcs[i];
10096 sprintf(msg,"FFC: %d Combo: %d\nCSet: %d Type: %s\nScript: %s",
10097 i+1, ff.data,ff.data,
10098 combo_class_buf[combobuf[ff.data].type].name,
10099 (ff.script<=0 ? "(None)" : ffcmap[ff.script-1].scriptname.substr(0,400).c_str()));
10100 ttip_install(mapscr_tooltip_id, msg, startxint+(ffx*mapscreen_single_scale), startyint+(ffy*mapscreen_single_scale), ffw*mapscreen_single_scale, ffh*mapscreen_single_scale, x, y);
10101 did_ffttip = true;
10102 break;
10103 }
10104 }
10105 if(!did_ffttip)
10106 {
10107 if(unsigned(c) < 176 && draw_mapscr && !gui_mouse_b())
10108 {
10109 int cid = draw_mapscr->data[c];
10110 newcombo const& cmb = combobuf[cid];
10111 std::ostringstream oss;
10112 int cs = draw_mapscr->cset[c];
10113 int sflag = draw_mapscr->sflag[c];
10114 oss << "Pos: " << c
10115 << "\nCombo: " << cid
10116 << "\nCSet: " << cs;
10117 if(sflag || cmb.flag)
10118 oss << "\nFlags: " << sflag << ", " << (int)cmb.flag;
10119 if(cmb.type)
10120 oss << "\nCombo type: " << combo_class_buf[cmb.type].name;
10121 if(cmb.label[0])
10122 oss << "\nLabel: " << cmb.label;
10123 ttip_install(mapscr_tooltip_id, oss.str().c_str(), startxint+(cx*16*mapscreen_single_scale), startyint+(cy*16*mapscreen_single_scale), 16*mapscreen_single_scale, 16*mapscreen_single_scale, x, y);
10124 }
10125 }
10126 }
10127
10128 {
10129 size_and_pos* squares[4] = {&itemsqr_pos,&stairsqr_pos,&warparrival_pos,&flagsqr_pos};
10130 for(int32_t j=0; j<4; j++)
10131 {
10132 auto& square = *squares[j];
10133 if(square.rect(x,y))
10134 {
10135 char msg[160];
10136 sprintf(msg,
10137 j==0 ? "Item Location" :
10138 j==1 ? "Stairs Secret\nTriggered when a Trigger Push Block is pushed." :
10139 j==2 ? "Arrival Square\nPlayer's location when they begin/resume the game." :
10140 "Combo Flags");
10141 update_tooltip(x,y,square,msg);
10142 }
10143 }
10144
10145 // Warp Returns
10146 for(int32_t j=0; j<4; j++)
10147 {
10148 size_and_pos& wret = warpret_pos[j];
10149 if(wret.rect(x,y))
10150 {
10151 char msg[160];
10152 sprintf(msg,"Warp Return Square %c\nPlayer's destination after warping to this screen.",(char)('A'+j));
10153 update_tooltip(x,y,wret,msg);
10154 }
10155 }
10156
10157 // Enemies
10158 if(enemy_prev_pos.rect(x,y))
10159 {
10160 char msg[160];
10161 sprintf(msg,"Enemies that appear on this screen.");
10162 update_tooltip(x,y,enemy_prev_pos,msg);
10163 }
10164
10165 int32_t cmd = commands_list.rectind(x,y);
10166 if(cmd > -1)
10167 {
10168 update_tooltip(x,y,commands_list.subsquare(cmd),
10169 fmt::format("Fav Command {}: {}\n{}", cmd,
10170 get_hotkey_name(favorite_commands[cmd]),
10171 get_hotkey_helptext(favorite_commands[cmd])).c_str());
10172 }
10173 }
10174
10175 if(draw_mode==dm_alias)
10176 {
10177 for(int32_t j=0; j<num_combo_cols; ++j)
10178 {
10179 auto& sqr = comboaliaslist[j];
10180 auto ind = sqr.rectind(x,y);
10181 if(ind > -1)
10182 {
10183 auto c2=ind+combo_alistpos[j];
10184 char msg[80];
10185 sprintf(msg, "Combo alias %d", c2);
10186 update_tooltip(x,y,sqr.subsquare(ind), msg);
10187 }
10188 }
10189 }
10190 else if(draw_mode==dm_cpool)
10191 {
10192 for(int32_t j=0; j<num_combo_cols; ++j)
10193 {
10194 auto& sqr = comboaliaslist[j];
10195 auto ind = sqr.rectind(x,y);
10196 if(ind > -1)
10197 {
10198 auto c2=ind+combo_pool_listpos[j];
10199 char msg[80];
10200 sprintf(msg, "Combo Pool %d", c2);
10201 update_tooltip(x,y,sqr.subsquare(ind), msg);
10202 }
10203 }
10204 if(cpool_prev_visible && combopool_prevbtn.rect(x,y))
10205 {
10206 if(do_layer_button_reset(combopool_prevbtn.x,combopool_prevbtn.y,
10207 combopool_prevbtn.w,combopool_prevbtn.h,
10208 weighted_cpool ? "Weighted" : "Unweighted",0,true))
10209 {
10210 weighted_cpool = !weighted_cpool;
10211 }
10212 }
10213 }
10214 else if (draw_mode == dm_auto)
10215 {
10216 for (int32_t j = 0; j < num_combo_cols; ++j)
10217 {
10218 auto& sqr = comboaliaslist[j];
10219 auto ind = sqr.rectind(x, y);
10220 if (ind > -1)
10221 {
10222 auto c2 = ind + combo_auto_listpos[j];
10223 char msg[80];
10224 sprintf(msg, "Auto Combo %d", c2);
10225 update_tooltip(x, y, sqr.subsquare(ind), msg);
10226 }
10227 }
10228 }
10229 else
10230 {
10231 if(combo_preview.rect(x,y))
10232 {
10233 auto str = "Combo Colors:\n"+get_combo_colornames(Combo,CSet);
10234 update_tooltip(x,y,combo_preview,str.c_str());
10235 }
10236 else if(comboprev_buf[0] && combo_preview_text1.rect(x,y))
10237 {
10238 update_tooltip(x,y,combo_preview_text1,comboprev_buf);
10239 }
10240 else if(comboprev_buf2[0] && combo_preview_text2.rect(x,y))
10241 {
10242 update_tooltip(x,y,combo_preview_text2,comboprev_buf2);
10243 }
10244 else for(int32_t j=0; j<num_combo_cols; ++j)
10245 {
10246 auto& sqr = combolist[j];
10247 auto ind = sqr.rectind(x,y);
10248 if(ind > -1)
10249 {
10250 int32_t c2=ind+First[j];
10251 std::ostringstream oss;
10252 newcombo const& cmb = combobuf[c2];
10253 oss << "Combo " << c2 << ": " << combo_class_buf[cmb.type].name;
10254 if(cmb.flag != 0)
10255 oss << "\nInherent flag: " << ZI.getMapFlagName(cmb.flag);
10256 if(!cmb.label.empty())
10257 oss << "\nLabel: " << cmb.label;
10258
10259 update_tooltip(x,y,sqr.subsquare(ind), oss.str().c_str());
10260 }
10261 }
10262 }
10263
10264 if (favorites_list.rect(x, y))
10265 {
10266 int32_t f = favorites_list.rectind(x, y);
10267 int32_t row = f / favorites_list.w;
10268 int32_t col = f % favorites_list.w;
10269 f = (row * FAVORITECOMBO_PER_ROW) + col;
10270
10271 auto& sqr = favorites_list.subsquare(col, row);
10272
10273 char buf[180];
10274 if (favorite_combos[f] == -1)
10275 sprintf(buf, "Fav Combo %d\nEmpty", f);
10276 else
10277 {
10278 switch (favorite_combo_modes[f])
10279 {
10280 case dm_alias:
10281 sprintf(buf, "Fav Combo %d\nAlias %d", f, favorite_combos[f]);
10282 break;
10283 case dm_cpool:
10284 sprintf(buf, "Fav Combo %d\nPool %d", f, favorite_combos[f]);
10285 break;
10286 case dm_auto:
10287 sprintf(buf, "Fav Combo %d\nAutocombo %d", f, favorite_combos[f]);
10288 break;
10289 default:
10290 sprintf(buf, "Fav Combo %d\nCombo %d", f, favorite_combos[f]);
10291 }
10292 }
10293 update_tooltip(x, y, sqr, buf);
10294 }
10295
10296 size_and_pos const& real_mini = zoomed_minimap ? real_minimap_zoomed : real_minimap;
10297 auto ind = real_mini.rectind(x,y);
10298 if(ind > -1)
10299 {
10300 char buf[80];
10301 sprintf(buf,"0x%02X (%d)", ind, ind);
10302 ttip_install(minimap_tooltip_id, buf, real_mini.subsquare(ind), real_mini.x+real_mini.tw(), real_mini.y-16);
10303 ttip_set_highlight_thickness(minimap_tooltip_id, zoomed_minimap ? 2 : 1);
10304 // Make sure always above the other tooltip items to the right of the map (even in big map mode).
10305 ttip_set_z_index(minimap_tooltip_id, 100);
10306 ttip_clear_timer();
10307 }
10308 else
10309 {
10310 ttip_uninstall(minimap_tooltip_id);
10311 }
10312
10313 // Mouse clicking stuff
10314 int real_mb = gui_mouse_b();
10315 int mb = real_mb & ~mouse_down; //Only handle clicks that have not been handled already
10316 auto mz = mouse_z;
10317 bool lclick = mb&1;
10318 bool rclick = mb&2;
10319
10320 FONT* tfont = font;
10321 if(zoomed_minimap)
10322 {
10323 if((lclick||rclick) && !minimap_zoomed.rect(x,y))
10324 {
10325 // 'Clicked off'
10326 mmap_set_zoom(false);
10327 goto domouse_doneclick;
10328 }
10329 }
10330
10331 if(real_mb==0)
10332 {
10333 mouse_down = 0;
10334 canfill=true;
10335 }
10336 else if(lclick || rclick)
10337 {
10338 //on the minimap
10339 if(real_mini.rect(x,y))
10340 {
10341 if(lclick)
10342 select_scr();
10343 else if(rclick && !(mouse_down&2))
10344 {
10345 mmap_set_zoom(!zoomed_minimap);
10346 }
10347 goto domouse_doneclick;
10348 }
10349
10350 if(zoomed_minimap && minimap_zoomed.rect(x,y))
10351 goto domouse_doneclick; //Eat clicks
10352
10353 //on the map tabs
10354 font = get_custom_font(CFONT_GUI);
10355 for(int32_t btn=0; btn<mappage_count; ++btn)
10356 {
10357 if (btn == current_mappage) continue;
10358 char tbuf[15];
10359 sprintf(tbuf, "%d:%02X", map_page[btn].map+1, map_page[btn].screen);
10360 auto& sqr = map_page_bar[btn];
10361 if(sqr.rect(x,y))
10362 {
10363 if(do_layer_button_reset(sqr.x,sqr.y,sqr.w,sqr.h,tbuf,(btn==current_mappage?D_SELECTED:0)))
10364 {
10365 draw_layer_button(screen, sqr.x,sqr.y,sqr.w,sqr.h,tbuf,D_SELECTED);
10366
10367 if (lclick)
10368 {
10369 map_page[current_mappage].map=Map.getCurrMap();
10370 map_page[current_mappage].screen=Map.getCurrScr();
10371 current_mappage=btn;
10372 Map.setCurrMap(map_page[current_mappage].map);
10373 Map.setCurrScr(map_page[current_mappage].screen);
10374 rebuild_trans_table(); //Woo
10375 }
10376 else if (rclick)
10377 {
10378 map_page[btn].map = 0;
10379 map_page[btn].screen = 0;
10380 }
10381 }
10382 goto domouse_doneclick;
10383 }
10384 }
10385
10386 if(compactbtn.rect(x,y))
10387 {
10388 if(do_text_button(compactbtn.x, compactbtn.y, compactbtn.w, compactbtn.h, is_compact ? "< Expand" : "> Compact"));
10389 toggle_is_compact();
10390 goto domouse_doneclick;
10391 }
10392
10393 if(!zoom_in_btn_disabled && zoominbtn.rect(x,y))
10394 {
10395 if(do_text_button(zoominbtn.x, zoominbtn.y, zoominbtn.w, zoominbtn.h, "+"))
10396 change_mapscr_zoom(-1);
10397 goto domouse_doneclick;
10398 }
10399
10400 if(!zoom_out_btn_disabled && zoomoutbtn.rect(x,y))
10401 {
10402 if(do_text_button(zoomoutbtn.x, zoomoutbtn.y, zoomoutbtn.w, zoomoutbtn.h, "-"))
10403 change_mapscr_zoom(1);
10404 goto domouse_doneclick;
10405 }
10406
10407 font = get_zc_font(font_lfont_l);
10408 if(combo_merge_btn.rect(x,y))
10409 {
10410 bool merged = is_compact ? compact_merged_combopane : large_merged_combopane;
10411 if(do_text_button(combo_merge_btn.x,combo_merge_btn.y,combo_merge_btn.w,combo_merge_btn.h,merged ? "<|>" : ">|<"))
10412 {
10413 toggle_merged_mode();
10414 }
10415 goto domouse_doneclick;
10416 }
10417
10418 if(favorites_zoombtn.rect(x,y))
10419 {
10420 bool zoomed = is_compact ? compact_zoomed_fav : large_zoomed_fav;
10421 if(do_text_button(favorites_zoombtn.x,favorites_zoombtn.y,favorites_zoombtn.w,favorites_zoombtn.h,zoomed ? "-" : "+"))
10422 {
10423 toggle_favzoom_mode();
10424 }
10425 goto domouse_doneclick;
10426 }
10427 else if(favorites_x.rect(x,y))
10428 {
10429 if(do_text_button(favorites_x.x,favorites_x.y,favorites_x.w,favorites_x.h,"X"))
10430 {
10431 AlertDialog("Clear Favorite Combos",
10432 "Are you sure you want to clear all favorite combos?",
10433 [&](bool ret,bool)
10434 {
10435 if(ret)
10436 {
10437 for(auto q = 0; q < MAXFAVORITECOMBOS; ++q)
10438 {
10439 favorite_combos[q] = -1;
10440 favorite_combo_modes[q] = dm_normal;
10441 }
10442 mark_save_dirty();
10443 refresh(rFAVORITES);
10444 }
10445 }).show();
10446 }
10447 goto domouse_doneclick;
10448 }
10449 else if(favorites_infobtn.rect(x,y))
10450 {
10451 if(do_text_button(favorites_infobtn.x,favorites_infobtn.y,favorites_infobtn.w,favorites_infobtn.h,"?"))
10452 {
10453 InfoDialog("Favorite Combos",
10454 "On LClick (empty): Sets clicked favorite to the current combo."
10455 "\nOn LClick: Sets current combo to clicked favorite."
10456 "\nShift+LClick: Sets clicked favorite to current combo."
10457 "\nCtrl+LClick: Clears clicked favorite."
10458 "\nAlt+LClick: Scrolls to clicked favorite."
10459 "\nRClick: Opens context menu."
10460 "\n\nClick the Page buttons (<-/->) to cycle between pages (RClick to jump to a page)"
10461 "\nClick the Zoom button (+/-) to toggle zoom level."
10462 "\nClick the X button to clear all favorite combos.").show();
10463 }
10464 goto domouse_doneclick;
10465 }
10466 else if(favorites_pgleft.rect(x,y))
10467 {
10468 if (do_text_button(favorites_pgleft.x, favorites_pgleft.y, favorites_pgleft.w, favorites_pgleft.h, is_compact ? "<" : "<-"))
10469 {
10470 if (rclick)
10471 {
10472 if(auto val = popup_num_menu(x, y, 1, 9, FavoriteComboPage, [](int p){return fmt::format("Page {}",p);}))
10473 FavoriteComboPage = vbound(*val-1, 0, 8);
10474 }
10475 else
10476 FavoriteComboPage = FavoriteComboPage == 0 ? 8 : --FavoriteComboPage;
10477 reload_zq_gui();
10478 }
10479 goto domouse_doneclick;
10480 }
10481 else if(favorites_pgright.rect(x,y))
10482 {
10483 if (do_text_button(favorites_pgright.x, favorites_pgright.y, favorites_pgright.w, favorites_pgright.h, is_compact ? ">" : "->"))
10484 {
10485 if (rclick)
10486 {
10487 if(auto val = popup_num_menu(x, y, 1, 9, FavoriteComboPage, [](int p){return fmt::format("Page {}",p);}))
10488 FavoriteComboPage = vbound(*val-1, 0, 8);
10489 }
10490 else
10491 FavoriteComboPage = FavoriteComboPage == 8 ? 0 : ++FavoriteComboPage;
10492 reload_zq_gui();
10493 }
10494 goto domouse_doneclick;
10495 }
10496
10497 if(commands_zoombtn.rect(x,y))
10498 {
10499 bool zoomed = is_compact ? compact_zoomed_cmd : large_zoomed_cmd;
10500 if(do_text_button(commands_zoombtn.x,commands_zoombtn.y,commands_zoombtn.w,commands_zoombtn.h,zoomed ? "-" : "+"))
10501 {
10502 toggle_cmdzoom_mode();
10503 }
10504 goto domouse_doneclick;
10505 }
10506 else if(commands_x.rect(x,y))
10507 {
10508 if(do_text_button(commands_x.x,commands_x.y,commands_x.w,commands_x.h,"X"))
10509 {
10510 AlertDialog("Clear Favorite Commands",
10511 "Are you sure you want to clear all favorite commands?",
10512 [&](bool ret,bool)
10513 {
10514 if(ret)
10515 {
10516 char buf[20];
10517 for(auto q = 0; q < MAXFAVORITECOMMANDS; ++q)
10518 {
10519 write_fav_command(q,0);
10520 }
10521 refresh(rFAVORITES);
10522 }
10523 }).show();
10524 }
10525 goto domouse_doneclick;
10526 }
10527 else if(commands_infobtn.rect(x,y))
10528 {
10529 if(do_text_button(commands_infobtn.x,commands_infobtn.y,commands_infobtn.w,commands_infobtn.h,"?"))
10530 {
10531 InfoDialog("Favorite Commands",
10532 "On LClick (empty): Choose a favorite command"
10533 "\nOn LClick: Runs the favorite command"
10534 "\nShift+Click: Choose a favorite command"
10535 "\nRClick: Choose a favorite command"
10536 "\nCtrl+Click: Clears clicked command"
10537 "\nAlt+Click: Shows info on the favorite command"
10538 "\n\nClick the Zoom button (+/-) to toggle zoom level"
10539 "\nClick the X button to clear all favorite commands").show();
10540 }
10541 goto domouse_doneclick;
10542 }
10543 font=tfont;
10544
10545 // On the layer panel
10546 font = get_custom_font(CFONT_GUI);
10547 for(int32_t i=0; i<=6; ++i)
10548 {
10549 int32_t spacing_offs = is_compact ? 2 : 10;
10550 int32_t rx = (i * (layerpanel_buttonwidth+spacing_offs+layerpanel_checkbox_wid)) + layer_panel.x+(is_compact?2:6);
10551 int32_t ry = layer_panel.y;
10552
10553 if (i != CurrentLayer && (i == 0 || mapscreen_valid_layers[i - 1]) && isinRect(x,y,rx,ry,rx+layerpanel_buttonwidth-1,ry+layerpanel_buttonheight-1))
10554 {
10555 char tbuf[15];
10556
10557 if (Map.getViewSize() > 1)
10558 {
10559 sprintf(tbuf, "%d", i);
10560 }
10561 else if (i != 0 && mapscreen_valid_layers[i - 1])
10562 {
10563 if (is_compact)
10564 {
10565 sprintf(tbuf, "%s%d %d:%02X",
10566 (i==2 && Map.CurrScr()->flags7&fLAYER2BG) || (i==3 && Map.CurrScr()->flags7&fLAYER3BG) ? "-":"",
10567 i, Map.CurrScr()->layermap[i-1], Map.CurrScr()->layerscreen[i-1]);
10568 }
10569 else
10570 {
10571 sprintf(tbuf, "%s%d (%d:%02X)",
10572 (i==2 && Map.CurrScr()->flags7&fLAYER2BG) || (i==3 && Map.CurrScr()->flags7&fLAYER3BG) ? "-":"",
10573 i, Map.CurrScr()->layermap[i-1], Map.CurrScr()->layerscreen[i-1]);
10574 }
10575 }
10576 else
10577 {
10578 sprintf(tbuf, "%d", i);
10579 }
10580
10581 if(do_text_button(rx, ry, layerpanel_buttonwidth, layerpanel_buttonheight, tbuf))
10582 {
10583 CurrentLayer = i;
10584 goto domouse_doneclick;
10585 }
10586 }
10587
10588 auto cbyofs = (layerpanel_buttonheight-layerpanel_checkbox_hei)/2;
10589 if(isinRect(x,y,rx+layerpanel_buttonwidth+1,ry+cbyofs,rx+layerpanel_buttonwidth+1+layerpanel_checkbox_wid-1,ry+2+layerpanel_checkbox_hei-1))
10590 {
10591 do_checkbox(screen,rx+layerpanel_buttonwidth+1,ry+cbyofs,layerpanel_checkbox_wid,layerpanel_checkbox_hei,LayerMaskInt[i]);
10592 goto domouse_doneclick;
10593 }
10594 }
10595 font=tfont;
10596
10597 //Uses lclick/rclick separately
10598
10599 //on the map screen
10600 if(isinRect(x,y,startxint,startyint,startxint+(256*mapscreen_screenunit_scale)-1,startyint+(176*mapscreen_screenunit_scale)-1))
10601 {
10602 if (lclick)
10603 {
10604 Map.setCurrScr(Map.getScreenForPosition(combo_pos));
10605 }
10606
10607 if (draw_mode == dm_auto)
10608 {
10609 if (CHECK_CTRL_CMD)
10610 {
10611 if (canfill)
10612 {
10613 switch (fill_type)
10614 {
10615 case 0:
10616 flood();
10617 break;
10618
10619 case 1:
10620 fill_4();
10621 break;
10622
10623 case 2:
10624 fill_8();
10625 break;
10626
10627 case 3:
10628 fill2_4();
10629 break;
10630
10631 case 4:
10632 fill2_8();
10633 break;
10634 }
10635
10636 canfill = false;
10637 }
10638 }
10639 else
10640 draw(key[KEY_LSHIFT] || key[KEY_RSHIFT]);
10641 }
10642 else if (scr && lclick)
10643 {
10644 int32_t cx2 = (x-startxint)/mapscreen_single_scale;
10645 int32_t cy2 = (y-startyint)/mapscreen_single_scale;
10646
10647 // Move items
10648 if (scr->hasitem && active_visible_screen)
10649 {
10650 int32_t ix = scr->itemx + active_visible_screen->dx * 256;
10651 int32_t iy = scr->itemy + active_visible_screen->dy * 176;
10652
10653 if(cx2 >= ix && cx2 < ix+16 && cy2 >= iy && cy2 < iy+16)
10654 doxypos(scr->itemx, scr->itemy, 11, SNAP_HALF, SNAP_NONE, true, 0, 0, 16, 16);
10655 }
10656
10657 // Move FFCs
10658 int num_ffcs = scr->numFFC();
10659 for(int32_t i=num_ffcs-1; i>=0; i--)
10660 if(scr->ffcs[i].data !=0 && (scr->ffcs[i].layer >= CurrentLayer || (!CurrentLayer && scr->ffcs[i].layer < 0) || (scr->ffcs[i].flags&ffc_overlay)))
10661 {
10662 int32_t ffx = scr->ffcs[i].x.getFloor() + active_visible_screen->dx * 256;
10663 int32_t ffy = scr->ffcs[i].y.getFloor() + active_visible_screen->dy * 176;
10664
10665 if(cx2 >= ffx && cx2 < ffx+(scr->ffTileWidth(i)*16) && cy2 >= ffy && cy2 < ffy+(scr->ffTileHeight(i)*16))
10666 {
10667 moveffc(i, cx2, cy2);
10668 break;
10669 }
10670 }
10671
10672 if(key[KEY_ALT]||key[KEY_ALTGR])
10673 {
10674 if (!draw_mapscr) return;
10675
10676 Combo=draw_mapscr->data[c];
10677 if(AutoBrush)
10678 BrushWidth = BrushHeight = 1;
10679 if(key[KEY_LSHIFT]||key[KEY_RSHIFT])
10680 CSet=draw_mapscr->cset[c];
10681 if(CHECK_CTRL_CMD)
10682 First[current_combolist]=scrollto_cmb(draw_mapscr->data[c]);
10683 }
10684 else if(CHECK_CTRL_CMD)
10685 {
10686 if(canfill)
10687 {
10688 switch(fill_type)
10689 {
10690 case 0:
10691 flood();
10692 break;
10693
10694 case 1:
10695 fill_4();
10696 break;
10697
10698 case 2:
10699 fill_8();
10700 break;
10701
10702 case 3:
10703 fill2_4();
10704 break;
10705
10706 case 4:
10707 fill2_8();
10708 break;
10709 }
10710
10711 canfill=false;
10712 }
10713 }
10714 else draw(key[KEY_LSHIFT] || key[KEY_RSHIFT]);
10715 }
10716 else if (scr && rclick)
10717 {
10718 ComboBrushPause=1;
10719 refresh(rMAP);
10720 restore_mouse();
10721 ComboBrushPause=0;
10722
10723 bool clickedffc = false;
10724
10725 // FFC right-click menu
10726 // This loop also serves to find the free ffc with the smallest slot number.
10727 int num_ffcs = scr->numFFC();
10728 uint32_t earliestfreeffc = num_ffcs;
10729 for(int32_t i=num_ffcs-1; i>=0; i--)
10730 {
10731 auto data = scr->ffcs[i].data;
10732 if(data==0)
10733 {
10734 if(i < earliestfreeffc)
10735 earliestfreeffc = i;
10736 continue;
10737 }
10738
10739 if(clickedffc || !(scr->valid&mVALID))
10740 continue;
10741
10742 if(data!=0 && (scr->ffcs[i].layer >= CurrentLayer || (!CurrentLayer && scr->ffcs[i].layer < 0) || (scr->ffcs[i].flags&ffc_overlay)))
10743 {
10744 int32_t ffx = scr->ffcs[i].x.getFloor() + active_visible_screen->dx * 256;
10745 int32_t ffy = scr->ffcs[i].y.getFloor() + active_visible_screen->dy * 176;
10746 int32_t cx2 = (x-startxint)/mapscreen_single_scale;
10747 int32_t cy2 = (y-startyint)/mapscreen_single_scale;
10748
10749 if(cx2 >= ffx && cx2 < ffx+(scr->ffTileWidth(i)*16) && cy2 >= ffy && cy2 < ffy+(scr->ffTileHeight(i)*16))
10750 {
10751 auto& ffc = scr->ffcs[i];
10752 NewMenu rcmenu
10753 {
10754 { "Copy FFC", [&](){Map.CopyFFC(active_visible_screen->screen, i);} },
10755 { "Paste FFC data", [&]()
10756 {
10757 bool didconfirm = false;
10758 AlertDialog("Confirm Paste",
10759 "Really replace the FFC with the data of the copied FFC?",
10760 [&](bool ret,bool)
10761 {
10762 if(ret)
10763 didconfirm = true;
10764 }).show();
10765 if(didconfirm)
10766 {
10767 auto set_ffc_data = Map.getCopyFFCData();
10768 set_ffc_data.x = scr->ffcs[i].x;
10769 set_ffc_data.y = scr->ffcs[i].y;
10770 Map.DoSetFFCCommand(Map.getCurrMap(), active_visible_screen->screen, i, set_ffc_data);
10771 }
10772 }, nullopt, Map.getCopyFFC() < 0 ? MFL_DIS : 0 },
10773 { "Edit FFC", [&](){call_ffc_dialog(i, active_visible_screen->scr, active_visible_screen->screen);} },
10774 { "Clear FFC", [&]()
10775 {
10776 bool didconfirm = false;
10777 AlertDialog("Confirm Clear",
10778 "Really clear this Freeform Combo?",
10779 [&](bool ret,bool)
10780 {
10781 if(ret)
10782 didconfirm = true;
10783 }).show();
10784 if(didconfirm)
10785 {
10786 Map.DoSetFFCCommand(Map.getCurrMap(), active_visible_screen->screen, i, {
10787 .x = 0,
10788 .y = 0,
10789 .vx = 0,
10790 .vy = 0,
10791 .ax = 0,
10792 .ay = 0,
10793 .data = 0,
10794 .cset = 0,
10795 .delay = 0,
10796 .link = 0,
10797 .script = 0,
10798 .tw = 1,
10799 .th = 1,
10800 .ew = 16,
10801 .eh = 16,
10802 .flags = ffc_none,
10803 .initd = 0,
10804 });
10805 mark_save_dirty();
10806 }
10807 } },
10808 { "Snap to Grid", [&]()
10809 {
10810 int oldffx = scr->ffcs[i].x.getInt();
10811 int oldffy = scr->ffcs[i].y.getInt();
10812 int pos = COMBOPOS(oldffx,oldffy);
10813 int newffy = COMBOY(pos);
10814 int newffx = COMBOX(pos);
10815
10816 auto set_ffc_data = set_ffc_command::create_data(scr->ffcs[i]);
10817 set_ffc_data.x = newffx;
10818 set_ffc_data.y = newffy;
10819 Map.DoSetFFCCommand(Map.getCurrMap(), active_visible_screen->screen, i, set_ffc_data);
10820
10821 mark_save_dirty();
10822 } },
10823 {},
10824 { "Select Combo", [&]()
10825 {
10826 Combo = ffc.data;
10827 } },
10828 { "Scroll to Combo", [&]()
10829 {
10830 First[current_combolist] = scrollto_cmb(ffc.data);
10831 } },
10832 { "Open Combo Page", [&]()
10833 {
10834 open_combo_pages(ffc.data);
10835 } },
10836 { "Edit Combo", [&]()
10837 {
10838 edit_combo(ffc.data,true,ffc.cset);
10839 } },
10840 };
10841 rcmenu.pop(x, y);
10842 clickedffc = true;
10843 break;
10844 }
10845 }
10846 }
10847
10848 // Combo right-click menu
10849 if(!clickedffc)
10850 {
10851 int warpindex = Map.warpindex(scr->data[c]);
10852 string txt_twarp_follow, txt_twarp_edit, txt_ffc_edit, txt_ffc_paste;
10853 bool show_ffcs = earliestfreeffc < MAXFFCS;
10854 bool dis_paste_ffc = Map.getCopyFFC() < 0;
10855 bool show_warps = warpindex > -1;
10856 bool show_warpback = Map.has_warpback();
10857 // FFC-specific options
10858 if(earliestfreeffc < MAXFFCS)
10859 {
10860 txt_ffc_edit = fmt::format("Edit New FFC {}",earliestfreeffc+1);
10861 if(Map.getCopyFFC()>-1)
10862 txt_ffc_paste = fmt::format("Paste FFC as FFC {}",earliestfreeffc+1);
10863 else
10864 txt_ffc_paste = "Paste FFC";
10865 }
10866
10867 if(warpindex > -1)
10868 {
10869 char letter = warpindex==4 ? 'R' : 'A'+warpindex;
10870 txt_twarp_follow = fmt::format("Follow Tile Warp {}",letter);
10871 txt_twarp_edit = fmt::format("Edit Tile Warp {}",letter);
10872 }
10873
10874 NewMenu draw_rc_menu
10875 {
10876 { "Select Combo", [&]()
10877 {
10878 Combo = draw_mapscr->data[c];
10879 if(AutoBrush)
10880 BrushWidth = BrushHeight = 1;
10881 }, nullopt, !draw_mapscr },
10882 { "Scroll to Combo", [&]()
10883 {
10884 First[current_combolist] = scrollto_cmb(draw_mapscr->data[c]);
10885 }, nullopt, !draw_mapscr },
10886 { "Open Combo Page", [&]()
10887 {
10888 open_combo_pages(draw_mapscr->data[c]);
10889 }, nullopt, !draw_mapscr },
10890 { "Edit Combo", [&]()
10891 {
10892 edit_combo(draw_mapscr->data[c],true,draw_mapscr->cset[c]);
10893 }, nullopt, !draw_mapscr },
10894 {},
10895 { "Replace All", [&](){replace(combo_pos);} },
10896 { "Draw Block", &draw_block_menu },
10897 { "Brush Settings ", &brush_menu },
10898 { "Set Fill Type ", &fill_menu },
10899 };
10900 if(show_warps || show_warpback)
10901 {
10902 draw_rc_menu.add_sep();
10903 if(show_warpback)
10904 draw_rc_menu.add({ "Warp Back", [&](){Map.warpback();} });
10905 if(show_warps)
10906 {
10907 draw_rc_menu.add({ txt_twarp_follow, [&](){follow_twarp(warpindex);} });
10908 draw_rc_menu.add({ txt_twarp_edit, [&](){edit_twarp(warpindex);} });
10909 }
10910 }
10911 if(show_ffcs)
10912 {
10913 draw_rc_menu.add_sep();
10914 draw_rc_menu.add({ txt_ffc_edit, [&]()
10915 {
10916 ffdata tempdat;
10917 // x, y are ints on ffdata (but ffc x, y are zfix), so *10000
10918 tempdat.x = ((int((x-startxint)/mapscreen_single_scale)&(~0x0007)) % 256) * 10000;
10919 tempdat.y = ((int((y-startyint)/mapscreen_single_scale)&(~0x0007)) % 176) * 10000;
10920 tempdat.data = Combo;
10921 tempdat.cset = CSet;
10922 if (SmartFFCPlacement)
10923 {
10924 tempdat.layer = CurrentLayer;
10925 SETFLAG(tempdat.flags, ffc_solid, (combobuf[Combo].walk & 0xF) == 0xF);
10926 }
10927 call_ffc_dialog(earliestfreeffc, tempdat, active_visible_screen->scr, active_visible_screen->screen);
10928 } });
10929 draw_rc_menu.add({ txt_ffc_paste, [&]()
10930 {
10931 auto set_ffc_data = Map.getCopyFFCData();
10932 set_ffc_data.x = ((int((x-startxint)/mapscreen_single_scale)&(~0x0007)) % 256);
10933 set_ffc_data.y = ((int((y-startyint)/mapscreen_single_scale)&(~0x0007)) % 176);
10934 Map.DoSetFFCCommand(Map.getCurrMap(), active_visible_screen->screen, earliestfreeffc, set_ffc_data);
10935 }, nullopt, dis_paste_ffc });
10936 }
10937 draw_rc_menu.add_sep();
10938 draw_rc_menu.add({ "Screen", &rc_menu_screen });
10939 draw_rc_menu.pop(x,y);
10940 }
10941 }
10942 goto domouse_doneclick;
10943 }
10944
10945 //on the drawing mode button
10946 font = get_custom_font(CFONT_GUI);
10947 if(drawmode_btn.rect(x,y))
10948 {
10949 if(lclick)
10950 {
10951 if(do_text_button(drawmode_btn.x,drawmode_btn.y,drawmode_btn.w,drawmode_btn.h,dm_names[draw_mode]))
10952 onDrawingMode();
10953 }
10954 else if(rclick)
10955 drawing_mode_menu.pop(x,y);
10956 goto domouse_doneclick;
10957 }
10958 font=tfont;
10959
10960 //Squares
10961 //
10962 set_active_visible_screen(Map.CurrScr());
10963 {
10964 if(squarepanel_swap_btn.rect(x,y))
10965 {
10966 toggle_compact_sqr_mode();
10967 goto domouse_doneclick;
10968 }
10969 if(squarepanel_up_btn.rect(x,y))
10970 {
10971 cycle_compact_sqr(false);
10972 goto domouse_doneclick;
10973 }
10974 if(squarepanel_down_btn.rect(x,y))
10975 {
10976 cycle_compact_sqr(true);
10977 goto domouse_doneclick;
10978 }
10979
10980 bool do_dummyxy = false;
10981 bool dummymode = key[KEY_LSHIFT] || key[KEY_RSHIFT];
10982
10983 if(itemsqr_pos.rect(x,y))
10984 {
10985 if(dummymode) do_dummyxy = true;
10986 else
10987 {
10988 onItem();
10989
10990 if(!rclick && Map.CurrScr()->hasitem)
10991 doxypos(Map.CurrScr()->itemx,Map.CurrScr()->itemy,11,SNAP_HALF,SNAP_NONE);
10992 goto domouse_doneclick;
10993 }
10994 }
10995
10996 if(stairsqr_pos.rect(x,y))
10997 {
10998 if(dummymode) do_dummyxy = true;
10999 else
11000 {
11001 doxypos(Map.CurrScr()->stairx,Map.CurrScr()->stairy,14,SNAP_WHOLE);
11002 goto domouse_doneclick;
11003 }
11004 }
11005
11006 if(warparrival_pos.rect(x,y))
11007 {
11008 if(dummymode) do_dummyxy = true;
11009 else
11010 {
11011 if(get_qr(qr_NOARRIVALPOINT))
11012 {
11013 info_dsa("Arrival Square",
11014 "The arrival square cannot be used unless the QR 'Use Warp Return "
11015 "Points Only' under 'Quest->Options->Combos' is disabled."
11016 "\nGenerally, this square only exists for compatibility purposes, and is not used"
11017 " in creating new quests.",
11018 "dsa_warparrival");
11019 }
11020 else doxypos(Map.CurrScr()->warparrivalx,Map.CurrScr()->warparrivaly,10,SNAP_HALF,SNAP_NONE);
11021 goto domouse_doneclick;
11022 }
11023 }
11024
11025 if(flagsqr_pos.rect(x,y))
11026 {
11027 if(dummymode) do_dummyxy = true;
11028 else
11029 {
11030 onFlags();
11031 goto domouse_doneclick;
11032 }
11033 }
11034
11035 for(auto q = 0; q < 4; ++q)
11036 {
11037 if(warpret_pos[q].rect(x,y))
11038 {
11039 if(dummymode) do_dummyxy = true;
11040 else
11041 {
11042 doxypos(Map.CurrScr()->warpreturnx[q],Map.CurrScr()->warpreturny[q],9,SNAP_HALF,SNAP_NONE);
11043 goto domouse_doneclick;
11044 }
11045 }
11046 }
11047
11048 if(enemy_prev_pos.rect(x,y))
11049 {
11050 if(dummymode) do_dummyxy = true;
11051 else
11052 {
11053 onEnemies();
11054 goto domouse_doneclick;
11055 }
11056 }
11057
11058 if(do_dummyxy)
11059 {
11060 byte x = 0, y = 0;
11061 showxypos_dummy = true;
11062 doxypos(x,y,13,SNAP_HALF,SNAP_NONE);
11063 goto domouse_doneclick;
11064 }
11065 }
11066
11067 if(draw_mode==dm_alias)
11068 {
11069 for(int32_t j=0; j<num_combo_cols; ++j)
11070 {
11071 if(combolistscrollers[j].rectind(x,y)==0 && !mouse_down)
11072 {
11073 scrollup(j);
11074 goto domouse_doneclick;
11075 }
11076 else if(combolistscrollers[j].rectind(x,y)==1 && !mouse_down)
11077 {
11078 scrolldown(j);
11079 goto domouse_doneclick;
11080 }
11081 else if(comboaliaslist[j].rect(x,y))
11082 {
11083 select_comboa(j);
11084
11085 if(rclick && comboaliaslist[j].rect(gui_mouse_x(),gui_mouse_y()))
11086 popup_cpane_rc(x, y);
11087 goto domouse_doneclick;
11088 }
11089 }
11090 }
11091 else if(draw_mode==dm_cpool)
11092 {
11093 for(int32_t j=0; j<num_combo_cols; ++j)
11094 {
11095 if(combolistscrollers[j].rectind(x,y)==0 && !mouse_down)
11096 {
11097 scrollup(j);
11098 goto domouse_doneclick;
11099 }
11100 else if(combolistscrollers[j].rectind(x,y)==1 && !mouse_down)
11101 {
11102 scrolldown(j);
11103 goto domouse_doneclick;
11104 }
11105 else if(comboaliaslist[j].rect(x,y))
11106 {
11107 select_combop(j);
11108
11109 if(rclick && comboaliaslist[j].rect(gui_mouse_x(),gui_mouse_y()))
11110 popup_cpane_rc(x, y);
11111 goto domouse_doneclick;
11112 }
11113 }
11114 }
11115 else if (draw_mode == dm_auto)
11116 {
11117 for (int32_t j = 0; j < num_combo_cols; ++j)
11118 {
11119 if (combolistscrollers[j].rectind(x, y) == 0 && !mouse_down)
11120 {
11121 scrollup(j);
11122 goto domouse_doneclick;
11123 }
11124 else if (combolistscrollers[j].rectind(x, y) == 1 && !mouse_down)
11125 {
11126 scrolldown(j);
11127 goto domouse_doneclick;
11128 }
11129 else if (comboaliaslist[j].rect(x, y))
11130 {
11131 select_autocombo(j);
11132
11133 if(rclick && comboaliaslist[j].rect(gui_mouse_x(),gui_mouse_y()))
11134 popup_cpane_rc(x, y);
11135 goto domouse_doneclick;
11136 }
11137 }
11138 }
11139 else
11140 {
11141 for(int32_t j=0; j<num_combo_cols; ++j)
11142 {
11143 if(combolistscrollers[j].rectind(x,y)==0 && !mouse_down)
11144 {
11145 scrollup(j);
11146 goto domouse_doneclick;
11147 }
11148 else if(combolistscrollers[j].rectind(x,y)==1 && !mouse_down)
11149 {
11150 scrolldown(j);
11151 goto domouse_doneclick;
11152 }
11153 else if(combolist[j].rect(x,y))
11154 {
11155 select_combo(j);
11156
11157 if(rclick && combolist[j].rect(gui_mouse_x(),gui_mouse_y()))
11158 popup_cpane_rc(x, y);
11159 goto domouse_doneclick;
11160 }
11161 }
11162 }
11163
11164 //on the favorites list
11165 if(favorites_list.rect(x,y))
11166 {
11167 if(lclick)
11168 {
11169 int32_t f=favorites_list.rectind(x,y);
11170 int32_t row=f/favorites_list.w;
11171 int32_t col=f%favorites_list.w;
11172 f = (row*FAVORITECOMBO_PER_ROW)+col;
11173 int32_t fp = f + FAVORITECOMBO_PER_PAGE * FavoriteComboPage;
11174
11175 bool dmcond = favorite_combos[fp] < 0;
11176 if((key[KEY_LSHIFT] || key[KEY_RSHIFT] || dmcond) && !(CHECK_CTRL_CMD))
11177 {
11178 int32_t tempcb=ComboBrush;
11179 ComboBrush=0;
11180
11181 while(gui_mouse_b())
11182 {
11183 x=gui_mouse_x();
11184 y=gui_mouse_y();
11185
11186 switch(draw_mode)
11187 {
11188 case dm_alias:
11189 if (favorite_combos[fp] != combo_apos || favorite_combo_modes[fp] != dm_alias)
11190 {
11191 favorite_combo_modes[fp] = dm_alias;
11192 favorite_combos[fp] = combo_apos;
11193 mark_save_dirty();
11194 }
11195 break;
11196 case dm_cpool:
11197 if (favorite_combos[fp] != combo_pool_pos || favorite_combo_modes[fp] != dm_cpool)
11198 {
11199 favorite_combo_modes[fp] = dm_cpool;
11200 favorite_combos[fp] = combo_pool_pos;
11201 mark_save_dirty();
11202 }
11203 break;
11204 case dm_auto:
11205 if (favorite_combos[fp] != combo_auto_pos || favorite_combo_modes[fp] != dm_auto)
11206 {
11207 favorite_combo_modes[fp] = dm_auto;
11208 favorite_combos[fp] = combo_auto_pos;
11209 mark_save_dirty();
11210 }
11211 break;
11212 default:
11213 if (favorite_combos[fp] != Combo || favorite_combo_modes[fp] != dm_normal)
11214 {
11215 if (BrushWidth > 1 || BrushHeight > 1)
11216 {
11217 add_favorite_combo_block(f, Combo, key[KEY_LSHIFT] || key[KEY_RSHIFT]);
11218 break;
11219 }
11220 favorite_combo_modes[fp] = dm_normal;
11221 favorite_combos[fp] = Combo;
11222 mark_save_dirty();
11223 }
11224 }
11225
11226 custom_vsync();
11227 refresh(rALL | rFAVORITES);
11228 }
11229
11230 ComboBrush=tempcb;
11231 }
11232 else if(CHECK_CTRL_CMD)
11233 {
11234 int32_t tempcb=ComboBrush;
11235 ComboBrush=0;
11236
11237 while(gui_mouse_b())
11238 {
11239 x=gui_mouse_x();
11240 y=gui_mouse_y();
11241
11242 if(favorite_combos[fp]!=-1)
11243 {
11244 favorite_combo_modes[fp] = dm_normal;
11245 favorite_combos[fp]=-1;
11246 mark_save_dirty();
11247 }
11248
11249 custom_vsync();
11250 refresh(rALL | rFAVORITES);
11251 }
11252
11253 ComboBrush=tempcb;
11254 }
11255 else if(key[KEY_ALT] || key[KEY_ALTGR])
11256 {
11257 if(select_favorite())
11258 {
11259 switch(favorite_combo_modes[fp])
11260 {
11261 case dm_alias:
11262 combo_alistpos[current_comboalist]=scrollto_alias(combo_apos);
11263 break;
11264 case dm_cpool:
11265 combo_pool_listpos[current_cpoollist] = scrollto_cpool(combo_pool_pos);
11266 break;
11267 case dm_auto:
11268 combo_auto_listpos[current_cautolist] = scrollto_cauto(combo_auto_pos);
11269 break;
11270 default:
11271 First[current_combolist]=scrollto_cmb(Combo);
11272 }
11273 }
11274 }
11275 else
11276 {
11277 select_favorite();
11278 }
11279 }
11280 else if(rclick)
11281 {
11282 bool valid=select_favorite();
11283
11284 if(valid)
11285 {
11286 int f = favorites_list.rectind(x,y);
11287 int row = f/favorites_list.w;
11288 int col = f%favorites_list.w;
11289 f = (row*FAVORITECOMBO_PER_ROW) + col + (FAVORITECOMBO_PER_PAGE * FavoriteComboPage);
11290 popup_favorites_rc(f, x, y);
11291 }
11292 }
11293 goto domouse_doneclick;
11294 }
11295
11296 //on the commands buttons
11297 int32_t cmd = commands_list.rectind(x,y);
11298 if(cmd > -1)
11299 {
11300 uint hkey = favorite_commands[cmd];
11301 bool shift=(key[KEY_LSHIFT] || key[KEY_RSHIFT]);
11302 bool ctrl=(CHECK_CTRL_CMD);
11303 bool alt=(key[KEY_ALT] || key[KEY_ALTGR]);
11304 bool dis = disabled_hotkey(hkey);
11305 auto& btn = commands_list.subsquare(cmd);
11306 if(!dis||rclick||shift||ctrl||alt)
11307 {
11308 FONT *tfont=font;
11309 font=get_custom_font(CFONT_FAVCMD);
11310 if(do_layer_button_reset(btn.x,btn.y,btn.w,btn.h,
11311 get_hotkey_name(hkey),
11312 selected_hotkey(hkey)?D_SELECTED:0,
11313 true))
11314 {
11315 font=tfont;
11316 if(alt)
11317 {
11318 show_hotkey_info(hkey);
11319 }
11320 else if(ctrl)
11321 {
11322 write_fav_command(cmd,0);
11323 }
11324 else if(rclick || shift || hkey==ZQKEY_NULL_KEY)
11325 {
11326 if(auto newkey = select_fav_command())
11327 write_fav_command(cmd,*newkey);
11328 }
11329 else
11330 {
11331 run_hotkey(hkey);
11332 }
11333 }
11334
11335 font=tfont;
11336 }
11337 goto domouse_doneclick;
11338 }
11339 }
11340
11341 domouse_doneclick:
11342 mouse_down |= mb&3;
11343
11344 if(mouse_z!=0)
11345 {
11346 int32_t z=0;
11347
11348 for(int32_t j=0; j<num_combo_cols; ++j)
11349 {
11350 z=abs(mouse_z);
11351
11352 if(key[KEY_ALT]||key[KEY_ALTGR])
11353 {
11354 z*=combolist[j].h;
11355 }
11356
11357
11358 if(draw_mode == dm_alias)
11359 {
11360 if(comboaliaslist[j].rect(x,y))
11361 {
11362 if(mouse_z<0) //scroll down
11363 {
11364 combo_alistpos[current_comboalist] = zc_min(MAXCOMBOALIASES - comboaliaslist[j].w*comboaliaslist[j].h,
11365 combo_alistpos[current_comboalist]+comboaliaslist[j].w*z);
11366 }
11367 else //scroll up
11368 {
11369 if(combo_alistpos[current_comboalist]>0)
11370 {
11371 combo_alistpos[current_comboalist]-=zc_min(combo_alistpos[current_comboalist],comboaliaslist[j].w*z);
11372 }
11373 }
11374 goto domouse_donez;
11375 }
11376 }
11377 else if(draw_mode == dm_cpool)
11378 {
11379 if(comboaliaslist[j].rect(x,y))
11380 {
11381 if(mouse_z<0) //scroll down
11382 {
11383 combo_pool_listpos[current_cpoollist] = zc_min(MAXCOMBOPOOLS - comboaliaslist[j].w*comboaliaslist[j].h,
11384 combo_pool_listpos[current_cpoollist]+comboaliaslist[j].w*z);
11385 }
11386 else //scroll up
11387 {
11388 if(combo_pool_listpos[current_cpoollist]>0)
11389 {
11390 combo_pool_listpos[current_cpoollist]-=zc_min(combo_pool_listpos[current_cpoollist],comboaliaslist[j].w*z);
11391 }
11392 }
11393 goto domouse_donez;
11394 }
11395 }
11396 else if (draw_mode == dm_auto)
11397 {
11398 if (comboaliaslist[j].rect(x, y))
11399 {
11400 if (mouse_z < 0) //scroll down
11401 {
11402 combo_auto_listpos[current_cautolist] = zc_min(MAXAUTOCOMBOS - comboaliaslist[j].w * comboaliaslist[j].h,
11403 combo_auto_listpos[current_cautolist] + comboaliaslist[j].w * z);
11404 }
11405 else //scroll up
11406 {
11407 if (combo_auto_listpos[current_cautolist] > 0)
11408 {
11409 combo_auto_listpos[current_cautolist] -= zc_min(combo_auto_listpos[current_cautolist], comboaliaslist[j].w * z);
11410 }
11411 }
11412 goto domouse_donez;
11413 }
11414 }
11415 else
11416 {
11417 if(combolist[j].rect(x,y))
11418 {
11419 if(mouse_z<0) //scroll down
11420 {
11421 First[current_combolist] = zc_min(MAXCOMBOS-combolist[j].w*combolist[j].h,
11422 First[current_combolist] + combolist[j].w*z);
11423 }
11424 else //scroll up
11425 {
11426 if(First[current_combolist]>0)
11427 {
11428 First[current_combolist]-=zc_min(First[current_combolist],combolist[j].w*z);
11429 }
11430 }
11431 goto domouse_donez;
11432 }
11433 }
11434 }
11435
11436 z=abs(mouse_z);
11437
11438 if(real_mini.rect(x,y))
11439 {
11440 for(int32_t i=0; i<z; ++i)
11441 {
11442 if(mouse_z>0) onIncMap();
11443 else onDecMap();
11444 }
11445 goto domouse_donez;
11446 }
11447
11448 if(is_compact && compact_square_panels
11449 && squares_panel.rect(x,y))
11450 {
11451 cycle_compact_sqr(mouse_z < 0);
11452 goto domouse_donez;
11453 }
11454 domouse_donez:
11455 position_mouse_z(0);
11456 }
11457
11458 // Mouse buttons.
11459 {
11460 ALLEGRO_MOUSE_STATE state;
11461 al_get_mouse_state(&state);
11462
11463 static bool btn_4_was_down;
11464 static bool btn_5_was_down;
11465
11466 bool btn_4_down = al_mouse_button_down(&state, 4);
11467 bool btn_5_down = al_mouse_button_down(&state, 5);
11468
11469 if (btn_4_was_down && !btn_4_down)
11470 Map.GoBack();
11471 else if (btn_5_was_down && !btn_5_down)
11472 Map.GoForward();
11473
11474 btn_4_was_down = btn_4_down;
11475 btn_5_was_down = btn_5_down;
11476 }
11477
11478 font = tfont;
11479 active_visible_screen = nullptr;
11480 }
11481
11482 int32_t d_viewpal_proc(int32_t msg, DIALOG *d, int32_t c)
11483 {
11484 int32_t ret = d_bitmap_proc(msg, d, c);
11485 char* buf = (char*)d->dp2; //buffer to store the color code in
11486 DIALOG* d2 = (DIALOG*)d->dp3; //DIALOG* to update the text proc
11487 if(!buf)
11488 return ret;
11489 switch(msg)
11490 {
11491 case MSG_IDLE:
11492 case MSG_GOTMOUSE:
11493 case MSG_LOSTMOUSE:
11494 break;
11495 default:
11496 return ret;
11497 }
11498 char t[16];
11499 memcpy(t, buf, 16);
11500 int32_t x = gui_mouse_x() - d->x;
11501 int32_t y = gui_mouse_y() - d->y;
11502 if(msg != MSG_LOSTMOUSE && isinRect(x, y, 0, 0, d->w-1, d->h-1))
11503 {
11504 float palscale = 1.5;
11505 for(int32_t i = 0; i<256; ++i)
11506 if(isinRect(x,y,(int32_t)(((i&31)<<3)*palscale),(int32_t)(((i&0xE0)>>2)*palscale), (int32_t)((((i&31)<<3)+7)*palscale),(int32_t)((((i&0xE0)>>2)+7)*palscale)))
11507 {
11508 sprintf(buf, "0x%02X (%03d) ", i, i); //Extra spaces to increase drawn width, so it draws the blank area
11509 break;
11510 }
11511 }
11512 else memset(buf, ' ', 15);
11513 if(strcmp(buf, t) && d2 && d2->proc == jwin_text_proc && d2->dp == d->dp2)
11514 object_message(d2, MSG_DRAW, 0);
11515 return ret;
11516 }
11517
11518 static DIALOG showpal_dlg[] =
11519 {
11520 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
11521 { jwin_win_proc, 24, 68, 272, 119, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "View Palette", NULL, NULL },
11522 { jwin_frame_proc, 30, 76+16, 260, 68, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
11523 { d_viewpal_proc, 32, 76+18, 256, 64, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
11524 { jwin_text_proc, 32+8,76+18+66, 20, 8, vc(11), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
11525 { jwin_button_proc, 130, 144+18, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
11526 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
11527 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
11528 };
11529
11530 int32_t onShowPal()
11531 {
11532 float palscale = 1.5;
11533
11534 BITMAP *palbmp = create_bitmap_ex(8,(int32_t)(256*palscale),(int32_t)(64*palscale));
11535
11536 if(!palbmp)
11537 return D_O_K;
11538 clear_to_color(palbmp,jwin_pal[jcBOX]); //If not cleared, random static appears between swatches! -E
11539 showpal_dlg[0].dp2=get_zc_font(font_lfont);
11540
11541 for(int32_t i=0; i<256; i++)
11542 rectfill(palbmp,(int32_t)(((i&31)<<3)*palscale),(int32_t)(((i&0xE0)>>2)*palscale), (int32_t)((((i&31)<<3)+7)*palscale),(int32_t)((((i&0xE0)>>2)+7)*palscale),i);
11543 showpal_dlg[2].dp=(void *)palbmp;
11544 char buf[16] = {0};
11545 showpal_dlg[2].dp2=(void *)buf;
11546 showpal_dlg[2].dp3=(void *)&(showpal_dlg[3]);
11547 showpal_dlg[3].dp=(void *)buf;
11548 showpal_dlg[3].dp2=(void *)get_zc_font(font_deffont);
11549
11550 large_dialog(showpal_dlg);
11551 do_zqdialog(showpal_dlg,2);
11552 destroy_bitmap(palbmp);
11553 return D_O_K;
11554 }
11555
11556 static DIALOG csetfix_dlg[] =
11557 {
11558 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
11559 { jwin_win_proc, 72, 80, 176+1, 96+1, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "CSet Fix", NULL, NULL },
11560 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
11561 { jwin_radio_proc, 104+22, 108, 80+1, 8+1, vc(14), vc(1), 0, 0, 0, 0, (void *) "Full Screen", NULL, NULL },
11562 { jwin_radio_proc, 104+22, 118+2, 80+1, 8+1, vc(14), vc(1), 0, D_SELECTED, 0, 0, (void *) "Dungeon Floor", NULL, NULL },
11563 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
11564 { jwin_check_proc, 104+22, 128+4, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, (void *) "All Layers", NULL, NULL },
11565 { jwin_button_proc, 90, 152, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
11566 { jwin_button_proc, 170, 152, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
11567 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
11568 };
11569
11570 int32_t onCSetFix()
11571 {
11572 restore_mouse();
11573 csetfix_dlg[0].dp2=get_zc_font(font_lfont);
11574 int32_t s=2,x2=14,y2=9;
11575
11576 large_dialog(csetfix_dlg);
11577
11578 if(do_zqdialog(csetfix_dlg,-1)==6)
11579 {
11580 if(csetfix_dlg[2].flags&D_SELECTED)
11581 {
11582 s=0;
11583 x2=16;
11584 y2=11;
11585 }
11586
11587 if(csetfix_dlg[5].flags&D_SELECTED)
11588 {
11589 /*
11590 int32_t drawmap, drawscr;
11591 if (CurrentLayer==0)
11592 {
11593 drawmap=Map.getCurrMap();
11594 drawscr=Map.getCurrScr();
11595 }
11596 else
11597 {
11598 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
11599 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
11600 }
11601 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
11602 if(!draw_mapscr) return;
11603 mark_save_dirty();
11604 Map.Ugo();
11605
11606 if(!(draw_mapscr->valid&mVALID))
11607 {
11608 Map.CurrScr()->valid|=mVALID;
11609 draw_mapscr->valid|=mVALID;
11610 Map.setcolor(Color);
11611 }
11612 for(int32_t i=0; i<176; i++)
11613 {
11614 draw_mapscr->data[i]=Combo;
11615 draw_mapscr->cset[i]=CSet;
11616 }
11617 refresh(rMAP+rSCRMAP);
11618 */
11619 }
11620
11621 Map.StartListCommand();
11622 for(int32_t y=s; y<y2; y++)
11623 {
11624 for(int32_t x=s; x<x2; x++)
11625 {
11626 Map.DoSetComboCommand(Map.getCurrMap(), Map.getCurrScr(), (y<<4)+x, -1, CSet);
11627 }
11628 }
11629 Map.FinishListCommand();
11630
11631 refresh(rMAP);
11632 mark_save_dirty();
11633 }
11634
11635 return D_O_K;
11636 }
11637 static bool doAllSolidWater()
11638 {
11639 for(int32_t i=0; i < MAXCOMBOS; ++i)
11640 {
11641 if(combo_class_buf[combobuf[i].type].water!=0)
11642 {
11643 combobuf[i].walk |= 0x0F; //Solid
11644 }
11645 }
11646 return true;
11647 }
11648 static bool doNoSolidWater()
11649 {
11650 for(int32_t i=0; i < MAXCOMBOS; ++i)
11651 {
11652 if(combo_class_buf[combobuf[i].type].water!=0)
11653 {
11654 combobuf[i].walk &= ~0x0F; //Non-solid
11655 }
11656 }
11657 return true;
11658 }
11659 int32_t onWaterSolidity()
11660 {
11661 AlertFuncDialog("Water Conversion",
11662 "Forcibly set the solidity of all 'Liquid' combos in the quest?",
11663 ""
11664 ).add_buttons(2,
11665 { "Solid", "Non-Solid", "Cancel" },
11666 { doAllSolidWater, doNoSolidWater, nullptr }
11667 ).show();
11668 return D_O_K;
11669 }
11670
11671 static bool doAllEffectSquare()
11672 {
11673 for(int32_t i=0; i < MAXCOMBOS; ++i)
11674 {
11675 combobuf[i].walk |= 0xF0; //Effect
11676 }
11677 return true;
11678 }
11679 static bool doBlankEffectSquare()
11680 {
11681 for(int32_t i=0; i < MAXCOMBOS; ++i)
11682 {
11683 if(combobuf[i].is_blank(true))
11684 {
11685 combobuf[i].walk |= 0xF0; //Effect
11686 }
11687 }
11688 return true;
11689 }
11690
11691 int32_t onEffectFix()
11692 {
11693 AlertFuncDialog("Effect Square Conversion",
11694 "Forcibly fill the green effect square of all combos in the quest?",
11695 ""
11696 ).add_buttons(2,
11697 { "All", "Blank Only", "Cancel" },
11698 { doAllEffectSquare, doBlankEffectSquare, nullptr }
11699 ).show();
11700 return D_O_K;
11701 }
11702
11703 static bool clear_green_arrival_squares()
11704 {
11705 for(mapscr& scr : TheMaps)
11706 {
11707 if(!scr.valid) continue;
11708 scr.warparrivalx = 0;
11709 scr.warparrivaly = 0;
11710 }
11711 set_qr(qr_NOARRIVALPOINT, true);
11712 return true;
11713 }
11714
11715 static bool replace_green_arrival_squares()
11716 {
11717 // Check for conflicts first
11718 bool has_conflicts = false;
11719
11720 for(mapscr& scr : TheMaps)
11721 {
11722 if(!scr.valid) continue;
11723 if(!(scr.warparrivalx || scr.warparrivaly)) continue;
11724 if(scr.warpreturnx[0] || scr.warpreturny[0])
11725 {
11726 has_conflicts = true;
11727 break;
11728 }
11729 }
11730
11731 enum
11732 {
11733 NOT_ASKED = -1,
11734 MODE_FORCE, MODE_IGNORE, MODE_FIND_IGNORE, MODE_FIND_FORCE, MODE_CANCEL
11735 };
11736 int mode = NOT_ASKED;
11737
11738 if(has_conflicts)
11739 {
11740 AlertFuncDialog("Handle Conflicts",
11741 "Warp Square A is not available for all screens that have arrival squares."
11742 " How should this be handled? (See '?' for more info)",
11743 "Overwrite A: Replace the existing warp return square A with the position of the green arrival square"
11744 "\nIgnore: Do nothing if warp return square A exists"
11745 "\nFind Space or Ignore: Choose another, unused, square to set to the position of the green arrival square."
11746 " If none are unused, 'Ignore' instead."
11747 "\nFind Space or Overwrite: Choose another, unused square to set to the position of the green arrival square."
11748 " If none are unused, 'Overwrite A' instead."
11749 "\nCancel: Don't do anything"
11750 ).add_buttons(1,
11751 { "Overwrite A", "Ignore", "Find Space or Ignore", "Find Space or Overwrite A", "Cancel" },
11752 mode
11753 ).show();
11754 if(mode == NOT_ASKED || mode == MODE_CANCEL)
11755 return false;
11756 }
11757 for(mapscr& scr : TheMaps)
11758 {
11759 if(!scr.valid) continue;
11760 if(!(scr.warparrivalx || scr.warparrivaly)) continue;
11761 int indx = 0;
11762 if(scr.warpreturnx[0] || scr.warpreturny[0])
11763 {
11764 if(mode == MODE_IGNORE) continue; // Warp A not free, so ignore
11765 if(mode != MODE_FORCE)
11766 {
11767 for(int q = 1; q < 4; ++q)
11768 {
11769 if(scr.warpreturnx[q] || scr.warpreturny[q])
11770 continue;
11771 indx = q; // Use this warp, since it's free
11772 break;
11773 }
11774 if(indx == 0 && mode == MODE_FIND_IGNORE)
11775 continue; // Nothing free, so ignore
11776 }
11777 }
11778 scr.warpreturnx[indx] = scr.warparrivalx;
11779 scr.warpreturny[indx] = scr.warparrivaly;
11780 scr.warparrivalx = 0;
11781 scr.warparrivaly = 0;
11782 }
11783 set_qr(qr_NOARRIVALPOINT, true);
11784 return true;
11785 }
11786
11787 int32_t onRemoveOldArrivalSquare()
11788 {
11789 AlertFuncDialog("Arrival Square Removal",
11790 "Clear the old green 'Arrival' squares for the whole quest?"
11791 "\n(There will be no further confirmation, and this operation cannot be undone)",
11792 ""
11793 ).add_buttons(2,
11794 { "Replace With Blue Return Square", "Clear Completely", "Cancel" },
11795 { replace_green_arrival_squares, clear_green_arrival_squares, nullptr }
11796 ).show();
11797 return D_O_K;
11798 }
11799
11800 byte* getPalPointer(int32_t pal, int32_t cset)
11801 {
11802 if (pal < 0) return colordata + CSET(cset)*3;
11803 byte* ret = colordata + CSET(pal*pdLEVEL+poLEVEL)*3;
11804 switch(cset)
11805 {
11806 case 2: case 3: case 4:
11807 return ret + CSET(cset-2)*3;
11808 case 9:
11809 return ret + CSET(3)*3;
11810 case 1:
11811 return ret + CSET(13)*3;
11812 case 5:
11813 return ret + CSET(14)*3;
11814 case 7:
11815 return ret + CSET(15)*3;
11816 case 8:
11817 return ret + CSET(16)*3;
11818 }
11819 return NULL;
11820 }
11821
11822 void copyCSet(int32_t destpal, int32_t destcset, int32_t srcpal, int32_t srccset)
11823 {
11824 byte* dest = getPalPointer(destpal, destcset);
11825 byte* src = getPalPointer(srcpal, srccset);
11826 if (dest && src)
11827 {
11828 memcpy(dest, src, 16*3);
11829 }
11830 }
11831
11832 void setColorPalette(int32_t flags, int32_t lowpal, int32_t highpal)
11833 {
11834 for (auto q = lowpal; q <= highpal; ++q)
11835 {
11836 for (auto c = 0; c < 12; ++c)
11837 {
11838 if (!(flags&(1<<c))) continue;
11839 copyCSet(q, c, -1, c);
11840 }
11841 }
11842 }
11843
11844 void setPitDamage(int32_t flags, int32_t lowcombo, int32_t highcombo, int32_t damage)
11845 {
11846 for(int32_t i=lowcombo; i < highcombo; ++i)
11847 {
11848 if((combobuf[i].type == cPITFALL && (flags & (1<<0)))
11849 || (combobuf[i].type == cWATER && !(combobuf[i].usrflags & (1<<0)) && (flags & (1<<1)))
11850 || (combobuf[i].type == cWATER && (combobuf[i].usrflags & (1<<0)) && (flags & (1<<2))))
11851 {
11852 if ((combobuf[i].type != cPITFALL || (flags & (1<<9)) || !(combobuf[i].usrflags & (1<<0)))
11853 && ((flags & (1<<8)) || combobuf[i].attributes[0] == 0))
11854 combobuf[i].attributes[0] = damage*10000;
11855 }
11856 }
11857 }
11858
11859 static DIALOG template_dlg[] =
11860 {
11861 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
11862 { jwin_win_proc, 72, 80, 176+1, 116+1, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "NES Dungeon Template", NULL, NULL },
11863 { d_comboframe_proc, 178, 122+3, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
11864 { d_combo_proc, 180, 124+3, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
11865 // { d_bitmap_proc, 180, 104, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
11866 { jwin_radio_proc, 104+33, 128+3, 64+1, 8+1, vc(14), vc(1), 0, D_SELECTED, 0, 0, (void *) "Floor:", NULL, NULL },
11867 { jwin_radio_proc, 104+33, 148+3, 64+1, 8+1, vc(14), vc(1), 0, 0, 0, 0, (void *) "No Floor", NULL, NULL },
11868 { jwin_button_proc, 90, 172, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
11869 { jwin_button_proc, 170, 172, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
11870 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
11871 { jwin_text_proc, 104, 102, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "This copies the contents of", NULL, NULL },
11872 { jwin_text_proc, 104, 112, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "screen 83 of the current map.", NULL, NULL },
11873 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
11874 };
11875
11876 int32_t onTemplate()
11877 {
11878 static bool donethis=false;
11879
11880 if(!donethis||!(key[KEY_LSHIFT]||key[KEY_RSHIFT]))
11881 {
11882 template_dlg[2].d1=Combo;
11883 template_dlg[2].fg=CSet;
11884 donethis=true;
11885 }
11886
11887 restore_mouse();
11888
11889 if(Map.getCurrScr()==TEMPLATE)
11890 return D_O_K;
11891
11892 // BITMAP *floor_bmp = create_bitmap_ex(8,16,16);
11893 // if(!floor_bmp) return D_O_K;
11894 template_dlg[0].dp2=get_zc_font(font_lfont);
11895 // put_combo(floor_bmp,0,0,Combo,CSet,0,0);
11896 // template_dlg[2].dp=floor_bmp;
11897
11898 large_dialog(template_dlg);
11899
11900 if(do_zqdialog(template_dlg,-1)==5)
11901 {
11902 mark_save_dirty();
11903 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
11904 Map.DoTemplateCommand((template_dlg[3].flags==D_SELECTED) ? template_dlg[2].d1 : -1, template_dlg[2].fg, screen);
11905 refresh(rMAP+rSCRMAP);
11906 }
11907
11908 // destroy_bitmap(floor_bmp);
11909 return D_O_K;
11910 }
11911
11912 static DIALOG cflag_dlg[] =
11913 {
11914 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
11915 12 { jwin_win_proc, 60-12, 40, 200+24, 148, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
11916 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
11917 12 { jwin_abclist_proc, 72-12-4, 60+4, 176+24+8, 92+3, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, NULL, NULL, NULL },
11918 12 { jwin_button_proc, 70, 163, 51, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
11919 12 { jwin_button_proc, 190, 163, 51, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
11920 12 { jwin_button_proc, 130, 163, 51, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Help", NULL, NULL },
11921 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
11922 };
11923
11924
11925 void questrev_help()
11926 {
11927 jwin_alert("Help","The revision number of your quest.",NULL,NULL,"O&K",NULL,'k',16,get_zc_font(font_lfont));
11928 }
11929
11930 void questminrev_help()
11931 {
11932 jwin_alert("Help","If a player's saved game was from a revision less than the minimum", "revision, they have to restart from the beginning.", "This is useful if you make major changes to your quest.","O&K",NULL,'k',16,get_zc_font(font_lfont));
11933 }
11934
11935 int32_t select_cflag(const char *prompt,int32_t flag)
11936 {
11937 cflag_dlg[0].dp=(void *)prompt;
11938 cflag_dlg[0].dp2=get_zc_font(font_lfont);
11939 GUI::ListData ld = GUI::ZCListData::mapflag(numericalFlags, true);
11940 ListData select_cflag_list = ld.getJWin(&font);
11941 auto index = ld.findIndex(flag);
11942 cflag_dlg[2].d1=index.value_or(0);
11943 cflag_dlg[2].dp=(void *) &select_cflag_list;
11944
11945 large_dialog(cflag_dlg);
11946
11947 int32_t ret;
11948
11949 do
11950 {
11951 ret=do_zqdialog(cflag_dlg,2);
11952
11953 if(ret==5)
11954 {
11955 cflag_help(ld.getValue(cflag_dlg[2].d1));
11956 }
11957 }
11958 while(ret==5);
11959
11960 if(ret==0||ret==4)
11961 {
11962 position_mouse_z(0);
11963 return -1;
11964 }
11965
11966 return ld.getValue(cflag_dlg[2].d1);
11967 }
11968
11969 int32_t select_flag(int32_t &f)
11970 {
11971 int32_t ret=select_cflag("Flag Type",f);
11972
11973 if(ret>=0)
11974 {
11975 f=ret;
11976 return true;
11977 }
11978
11979 return false;
11980 }
11981
11982 int32_t d_scombo_proc(int32_t msg,DIALOG *d,int32_t c)
11983 {
11984 //these are here to bypass compiler warnings about unused arguments
11985 c=c;
11986
11987 switch(msg)
11988 {
11989 case MSG_CLICK:
11990 {
11991 int32_t c2=d->d1;
11992 int32_t cs=d->fg;
11993 int32_t f=d->d2;
11994
11995 if(d->bg==1 || (CHECK_CTRL_CMD))
11996 {
11997 while(gui_mouse_b())
11998 {
11999 /* do nothing */
12000 rest(1);
12001 }
12002
12003 if(select_flag(f))
12004 {
12005 d->d2=f;
12006
12007 }
12008 }
12009 else if(key[KEY_LSHIFT])
12010 {
12011 if(gui_mouse_b()&1)
12012 {
12013 d->d1++;
12014
12015 if(d->d1>=MAXCOMBOS) d->d1=0;
12016 }
12017 else if(gui_mouse_b()&2)
12018 {
12019 d->d1--;
12020
12021 if(d->d1<0) d->d1=MAXCOMBOS-1;
12022 }
12023 }
12024 else if(key[KEY_RSHIFT])
12025 {
12026 if(gui_mouse_b()&1)
12027 {
12028 d->fg++;
12029
12030 if(d->fg>11) d->fg=0;
12031 }
12032 else if(gui_mouse_b()&2)
12033 {
12034 d->fg--;
12035
12036 if(d->fg<0) d->fg=11;
12037 }
12038 }
12039 else if(key[KEY_ALT])
12040 {
12041 if(gui_mouse_b()&1)
12042 {
12043 d->d1 = Combo;
12044 d->fg = CSet;
12045 }
12046 }
12047 else
12048 {
12049 if(select_combo_2(c2, cs))
12050 {
12051 d->d1=c2;
12052 d->fg=cs;
12053 }
12054 }
12055
12056 return D_REDRAW;
12057 }
12058 break;
12059
12060 case MSG_DRAW:
12061 d->w = 32;
12062 d->h = 32;
12063
12064 BITMAP *buf = create_bitmap_ex(8,16,16);
12065 BITMAP *bigbmp = create_bitmap_ex(8,d->w,d->h);
12066
12067 if(buf && bigbmp)
12068 {
12069 clear_bitmap(buf);
12070
12071 if(d->bg) //flags only
12072 {
12073 put_flag(buf,0,0,d->d2);
12074 }
12075 else if(d->d1)
12076 {
12077 putcombo(buf,0,0,d->d1,d->fg);
12078
12079 if(Flags&cFLAGS)
12080 put_flags(buf,0,0,d->d1,d->fg,cFLAGS,d->d2);
12081 }
12082
12083 stretch_blit(buf, bigbmp, 0,0, 16, 16, 0, 0, d->w, d->h);
12084 destroy_bitmap(buf);
12085 blit(bigbmp,screen,0,0,d->x-1,d->y-1,d->w,d->h);
12086 destroy_bitmap(bigbmp);
12087 }
12088
12089
12090 /*BITMAP *buf = create_bitmap_ex(8,16,16);
12091 if(buf)
12092 {
12093 clear_bitmap(buf);
12094 if(d->d1)
12095 putcombo(buf,0,0,d->d1,d->fg);
12096
12097 blit(buf,screen,0,0,d->x,d->y,d->w,d->h);
12098 destroy_bitmap(buf);
12099 }*/
12100 break;
12101 }
12102
12103 return D_O_K;
12104 }
12105
12106 int32_t onSecretF();
12107
12108 static int32_t secret_burn_list[] =
12109 {
12110 // dialog control number
12111 4, 5, 6, 7, 48, 49, 50, 51, 92, 93, 94, 95, -1
12112 };
12113
12114 static int32_t secret_arrow_list[] =
12115 {
12116 // dialog control number
12117 8, 9, 10, 52, 53, 54, 96, 97, 98, -1
12118 };
12119
12120 static int32_t secret_bomb_list[] =
12121 {
12122 // dialog control number
12123 11, 12, 55, 56, 99, 100, -1
12124 };
12125
12126 static int32_t secret_boomerang_list[] =
12127 {
12128 // dialog control number
12129 13, 14, 15, 57, 58, 59, 101, 102, 103, -1
12130 };
12131
12132 static int32_t secret_magic_list[] =
12133 {
12134 // dialog control number
12135 16, 17, 60, 61, 104, 105, -1
12136 };
12137
12138 static int32_t secret_sword_list[] =
12139 {
12140 // dialog control number
12141 18, 19, 20, 21, 22, 23, 24, 25, 62, 63, 64, 65, 66, 67, 68, 69, 106, 107, 108, 109, 110, 111, 112, 113, -1
12142 };
12143
12144 static int32_t secret_misc_list[] =
12145 {
12146 // dialog control number
12147 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, -1
12148 };
12149
12150 static TABPANEL secret_tabs[] =
12151 {
12152 // (text)
12153 { (char *)"Burn", D_SELECTED, secret_burn_list, 0, NULL },
12154 { (char *)"Arrow", 0, secret_arrow_list, 0, NULL },
12155 { (char *)"Bomb", 0, secret_bomb_list, 0, NULL },
12156 { (char *)"Boomerang", 0, secret_boomerang_list, 0, NULL },
12157 { (char *)"Magic", 0, secret_magic_list, 0, NULL },
12158 { (char *)"Sword", 0, secret_sword_list, 0, NULL },
12159 { (char *)"Misc", 0, secret_misc_list, 0, NULL },
12160 { NULL, 0, NULL, 0, NULL }
12161 };
12162
12163 static DIALOG secret_dlg[] =
12164 {
12165 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
12166 { jwin_win_proc, 0, 0, 301, 212, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
12167 { jwin_tab_proc, 6, 25, 289, 156, 0, 0, 0, 0, 0, 0, (void *) secret_tabs, NULL, (void *)secret_dlg },
12168 { jwin_button_proc, 80, 187, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
12169 { jwin_button_proc, 160, 187, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
12170 // 4
12171 { jwin_text_proc, 12, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Any Fire", NULL, NULL },
12172 { jwin_text_proc, 12, 75, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Strong Fire", NULL, NULL },
12173 { jwin_text_proc, 12, 97, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Magic Fire", NULL, NULL },
12174 { jwin_text_proc, 12, 119, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Divine Fire", NULL, NULL },
12175 //8
12176 { jwin_text_proc, 12, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Wooden Arrow", NULL, NULL },
12177 { jwin_text_proc, 12, 75, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Silver Arrow", NULL, NULL },
12178 { jwin_text_proc, 12, 97, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Golden Arrow", NULL, NULL },
12179 //11
12180 { jwin_text_proc, 12, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Bomb", NULL, NULL },
12181 { jwin_text_proc, 12, 75, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Super Bomb", NULL, NULL },
12182 //13
12183 { jwin_text_proc, 12, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Wooden Boomerang", NULL, NULL },
12184 { jwin_text_proc, 12, 75, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Magic Boomerang", NULL, NULL },
12185 { jwin_text_proc, 12, 97, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Fire Boomerang", NULL, NULL },
12186 //16
12187 { jwin_text_proc, 12, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Wand Magic", NULL, NULL },
12188 { jwin_text_proc, 12, 75, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Reflected Magic", NULL, NULL },
12189 //18
12190 { jwin_text_proc, 12, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Sword", NULL, NULL },
12191 { jwin_text_proc, 12, 75, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "White Sword", NULL, NULL },
12192 { jwin_text_proc, 12, 97, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Magic Sword", NULL, NULL },
12193 { jwin_text_proc, 12, 119, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Master Sword", NULL, NULL },
12194 { jwin_text_proc, 160, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Sword Beam", NULL, NULL },
12195 { jwin_text_proc, 160, 75, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "White Sword Beam", NULL, NULL },
12196 { jwin_text_proc, 160, 97, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Magic Sword Beam", NULL, NULL },
12197 { jwin_text_proc, 160, 119, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Master Sword Beam", NULL, NULL },
12198 //26
12199 { jwin_text_proc, 12, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Stairs", NULL, NULL },
12200 { jwin_text_proc, 12, 75, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Reflected Fireball", NULL, NULL },
12201 { jwin_text_proc, 12, 97, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Hookshot", NULL, NULL },
12202 { jwin_text_proc, 12, 119, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Wand", NULL, NULL },
12203 { jwin_text_proc, 12, 141, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Hammer", NULL, NULL },
12204 { jwin_text_proc, 12, 163, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Any Weapon", NULL, NULL },
12205 //32
12206 { jwin_ctext_proc, 235, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Flags 16-31", NULL, NULL },
12207 { jwin_text_proc, 87, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Secrets->Next (Flag only)", NULL, NULL },
12208 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 03", NULL, NULL },
12209 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 04", NULL, NULL },
12210 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 05", NULL, NULL },
12211 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 06", NULL, NULL },
12212 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 07", NULL, NULL },
12213 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 08", NULL, NULL },
12214 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 09", NULL, NULL },
12215 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 10", NULL, NULL },
12216 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 11", NULL, NULL },
12217 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 12", NULL, NULL },
12218 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 13", NULL, NULL },
12219 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 14", NULL, NULL },
12220 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 15", NULL, NULL },
12221 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 16", NULL, NULL },
12222 //48 (burn)
12223 { jwin_frame_proc, 108, 47, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12224 { jwin_frame_proc, 108, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12225 { jwin_frame_proc, 108, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12226 { jwin_frame_proc, 108, 113, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12227 //52 (arrow)
12228 { jwin_frame_proc, 108, 47, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12229 { jwin_frame_proc, 108, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12230 { jwin_frame_proc, 108, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12231 //55 (bomb)
12232 { jwin_frame_proc, 108, 47, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12233 { jwin_frame_proc, 108, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12234 //57 (boomerang)
12235 { jwin_frame_proc, 108, 47, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12236 { jwin_frame_proc, 108, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12237 { jwin_frame_proc, 108, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12238 //60 (magic)
12239 { jwin_frame_proc, 108, 47, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12240 { jwin_frame_proc, 108, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12241 //62 (sword)
12242 { jwin_frame_proc, 108, 47, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12243 { jwin_frame_proc, 108, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12244 { jwin_frame_proc, 108, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12245 { jwin_frame_proc, 108, 113, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12246 { jwin_frame_proc, 256, 47, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12247 { jwin_frame_proc, 256, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12248 { jwin_frame_proc, 256, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12249 { jwin_frame_proc, 256, 113, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12250 //70 (misc)
12251 { jwin_frame_proc, 63, 47, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12252 { jwin_frame_proc, 63, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12253 { jwin_frame_proc, 63, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12254 { jwin_frame_proc, 63, 113, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12255 { jwin_frame_proc, 63, 135, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12256 { jwin_frame_proc, 63, 157, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12257 //76 (16-32)
12258 { jwin_frame_proc, 192, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12259 { jwin_frame_proc, 214, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12260 { jwin_frame_proc, 236, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12261 { jwin_frame_proc, 258, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12262 { jwin_frame_proc, 192, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12263 { jwin_frame_proc, 214, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12264 { jwin_frame_proc, 236, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12265 { jwin_frame_proc, 258, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12266 { jwin_frame_proc, 192, 113, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12267 { jwin_frame_proc, 214, 113, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12268 { jwin_frame_proc, 236, 113, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12269 { jwin_frame_proc, 258, 113, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12270 { jwin_frame_proc, 192, 135, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12271 { jwin_frame_proc, 214, 135, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12272 { jwin_frame_proc, 236, 135, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12273 { jwin_frame_proc, 258, 135, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12274
12275 //92 (burn)
12276 { d_scombo_proc, 110, 49, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12277 { d_scombo_proc, 110, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12278 { d_scombo_proc, 110, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12279 { d_scombo_proc, 110, 115, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12280 //96 (arrow)
12281 { d_scombo_proc, 110, 49, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12282 { d_scombo_proc, 110, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12283 { d_scombo_proc, 110, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12284 //99 (bomb)
12285 { d_scombo_proc, 110, 49, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12286 { d_scombo_proc, 110, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12287 //101 (boomerang)
12288 { d_scombo_proc, 110, 49, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12289 { d_scombo_proc, 110, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12290 { d_scombo_proc, 110, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12291 //104 (magic)
12292 { d_scombo_proc, 110, 49, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12293 { d_scombo_proc, 110, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12294 //106 (sword)
12295 { d_scombo_proc, 110, 49, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12296 { d_scombo_proc, 110, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12297 { d_scombo_proc, 110, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12298 { d_scombo_proc, 110, 115, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12299 { d_scombo_proc, 258, 49, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12300 { d_scombo_proc, 258, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12301 { d_scombo_proc, 258, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12302 { d_scombo_proc, 258, 115, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12303 //114 (misc)
12304 { d_scombo_proc, 65, 49, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12305 { d_scombo_proc, 65, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12306 { d_scombo_proc, 65, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12307 { d_scombo_proc, 65, 115, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12308 { d_scombo_proc, 65, 137, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12309 { d_scombo_proc, 65, 159, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12310 //120 (16-32)
12311 { d_scombo_proc, 194, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12312 { d_scombo_proc, 216, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12313 { d_scombo_proc, 238, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12314 { d_scombo_proc, 260, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12315 { d_scombo_proc, 194, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12316 { d_scombo_proc, 216, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12317 { d_scombo_proc, 238, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12318 { d_scombo_proc, 260, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12319 { d_scombo_proc, 194, 115, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12320 { d_scombo_proc, 216, 115, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12321 { d_scombo_proc, 238, 115, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12322 { d_scombo_proc, 260, 115, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12323 { d_scombo_proc, 194, 137, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12324 { d_scombo_proc, 216, 137, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12325 { d_scombo_proc, 238, 137, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12326 { d_scombo_proc, 260, 137, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12327 //136 Secrets->Next
12328 { jwin_frame_proc, 158, 47, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12329 { d_scombo_proc, 160, 49, 16, 16, 0, 1, 0, 0, 0, 0, NULL, NULL, NULL },
12330 //138
12331 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onHelp, NULL, NULL },
12332 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 'f', 0, 0, 0, (void *) onSecretF, NULL, NULL },
12333 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12334 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
12335 };
12336
12337 int32_t onSecretF()
12338 {
12339 Flags^=cFLAGS;
12340 object_message(secret_dlg+1, MSG_DRAW, 0);
12341 return D_O_K;
12342 }
12343
12344
12345 int32_t onSecretCombo()
12346 {
12347 secret_dlg[0].dp2=get_zc_font(font_lfont);
12348
12349
12350 mapscr *s;
12351
12352 if(CurrentLayer==0)
12353 {
12354 s=Map.CurrScr();
12355 }
12356 else
12357 {
12358 // s=TheMaps[(Map.CurrScr()->layermap[CurrentLayer-1]-1)*MAPSCRS+(Map.CurrScr()->layerscreen[CurrentLayer-1])];
12359 s=Map.AbsoluteScr((Map.CurrScr()->layermap[CurrentLayer-1]-1), (Map.CurrScr()->layerscreen[CurrentLayer-1]));
12360 }
12361 if(!s) return D_O_K;
12362
12363 char secretcombonumstr[27];
12364 sprintf(secretcombonumstr,"Secret Combos for Layer %d", CurrentLayer);
12365 secret_dlg[0].dp = secretcombonumstr;
12366
12367 secret_dlg[92].d1 = s->secretcombo[sBCANDLE];
12368 secret_dlg[92].fg = s->secretcset[sBCANDLE];
12369 secret_dlg[92].d2 = s->secretflag[sBCANDLE];
12370
12371 secret_dlg[93].d1 = s->secretcombo[sRCANDLE];
12372 secret_dlg[93].fg = s->secretcset[sRCANDLE];
12373 secret_dlg[93].d2 = s->secretflag[sRCANDLE];
12374
12375 secret_dlg[94].d1 = s->secretcombo[sWANDFIRE];
12376 secret_dlg[94].fg = s->secretcset[sWANDFIRE];
12377 secret_dlg[94].d2 = s->secretflag[sWANDFIRE];
12378
12379 secret_dlg[95].d1 = s->secretcombo[sDIVINEFIRE];
12380 secret_dlg[95].fg = s->secretcset[sDIVINEFIRE];
12381 secret_dlg[95].d2 = s->secretflag[sDIVINEFIRE];
12382
12383 secret_dlg[96].d1 = s->secretcombo[sARROW];
12384 secret_dlg[96].fg = s->secretcset[sARROW];
12385 secret_dlg[96].d2 = s->secretflag[sARROW];
12386
12387 secret_dlg[97].d1 = s->secretcombo[sSARROW];
12388 secret_dlg[97].fg = s->secretcset[sSARROW];
12389 secret_dlg[97].d2 = s->secretflag[sSARROW];
12390
12391 secret_dlg[98].d1 = s->secretcombo[sGARROW];
12392 secret_dlg[98].fg = s->secretcset[sGARROW];
12393 secret_dlg[98].d2 = s->secretflag[sGARROW];
12394
12395 secret_dlg[99].d1 = s->secretcombo[sBOMB];
12396 secret_dlg[99].fg = s->secretcset[sBOMB];
12397 secret_dlg[99].d2 = s->secretflag[sBOMB];
12398
12399 secret_dlg[100].d1 = s->secretcombo[sSBOMB];
12400 secret_dlg[100].fg = s->secretcset[sSBOMB];
12401 secret_dlg[100].d2 = s->secretflag[sSBOMB];
12402
12403 for(int32_t i=0; i<3; i++)
12404 {
12405 secret_dlg[101+i].d1 = s->secretcombo[sBRANG+i];
12406 secret_dlg[101+i].fg = s->secretcset[sBRANG+i];
12407 secret_dlg[101+i].d2 = s->secretflag[sBRANG+i];
12408 }
12409
12410 for(int32_t i=0; i<2; i++)
12411 {
12412 secret_dlg[104+i].d1 = s->secretcombo[sWANDMAGIC+i];
12413 secret_dlg[104+i].fg = s->secretcset[sWANDMAGIC+i];
12414 secret_dlg[104+i].d2 = s->secretflag[sWANDMAGIC+i];
12415 }
12416
12417 for(int32_t i=0; i<8; i++)
12418 {
12419 secret_dlg[106+i].d1 = s->secretcombo[sSWORD+i];
12420 secret_dlg[106+i].fg = s->secretcset[sSWORD+i];
12421 secret_dlg[106+i].d2 = s->secretflag[sSWORD+i];
12422 }
12423
12424 secret_dlg[114].d1 = s->secretcombo[sSTAIRS];
12425 secret_dlg[114].fg = s->secretcset[sSTAIRS];
12426 secret_dlg[114].d2 = s->secretflag[sSTAIRS];
12427
12428 secret_dlg[115].d1 = s->secretcombo[sREFFIREBALL];
12429 secret_dlg[115].fg = s->secretcset[sREFFIREBALL];
12430 secret_dlg[115].d2 = s->secretflag[sREFFIREBALL];
12431
12432 for(int32_t i=0; i<4; i++)
12433 {
12434 secret_dlg[116+i].d1 = s->secretcombo[sHOOKSHOT+i];
12435 secret_dlg[116+i].fg = s->secretcset[sHOOKSHOT+i];
12436 secret_dlg[116+i].d2 = s->secretflag[sHOOKSHOT+i];
12437 }
12438
12439 for(int32_t i=0; i<16; i++)
12440 {
12441 secret_dlg[120+i].d1 = s->secretcombo[sSECRET01+i];
12442 secret_dlg[120+i].fg = s->secretcset[sSECRET01+i];
12443 secret_dlg[120+i].d2 = s->secretflag[sSECRET01+i];
12444 }
12445
12446 //Sec->Next doesn't have a combo/cset value associated
12447 secret_dlg[137].d1 = 0;
12448 secret_dlg[137].fg = 0;
12449 secret_dlg[137].d2 = s->secretflag[sSECNEXT];
12450
12451 large_dialog(secret_dlg,1.75);
12452
12453 for(int32_t q = 0; secret_dlg[q].proc != NULL; ++q)
12454 {
12455 if(secret_dlg[q].proc == jwin_frame_proc)
12456 secret_dlg[q].w = secret_dlg[q].h = 36;
12457 }
12458
12459 if(do_zqdialog(secret_dlg,3) == 2)
12460 {
12461 mark_save_dirty();
12462 s->secretcombo[sBCANDLE] = secret_dlg[92].d1;
12463 s->secretcset[sBCANDLE] = secret_dlg[92].fg;
12464 s->secretflag[sBCANDLE] = secret_dlg[92].d2;
12465
12466 s->secretcombo[sRCANDLE] = secret_dlg[93].d1;
12467 s->secretcset[sRCANDLE] = secret_dlg[93].fg;
12468 s->secretflag[sRCANDLE] = secret_dlg[93].d2;
12469
12470 s->secretcombo[sWANDFIRE] = secret_dlg[94].d1;
12471 s->secretcset[sWANDFIRE] = secret_dlg[94].fg;
12472 s->secretflag[sWANDFIRE] = secret_dlg[94].d2;
12473
12474 s->secretcombo[sDIVINEFIRE] = secret_dlg[95].d1;
12475 s->secretcset[sDIVINEFIRE] = secret_dlg[95].fg;
12476 s->secretflag[sDIVINEFIRE] = secret_dlg[95].d2;
12477
12478 s->secretcombo[sARROW] = secret_dlg[96].d1;
12479 s->secretcset[sARROW] = secret_dlg[96].fg;
12480 s->secretflag[sARROW] = secret_dlg[96].d2;
12481
12482 s->secretcombo[sSARROW] = secret_dlg[97].d1;
12483 s->secretcset[sSARROW] = secret_dlg[97].fg;
12484 s->secretflag[sSARROW] = secret_dlg[97].d2;
12485
12486 s->secretcombo[sGARROW] = secret_dlg[98].d1;
12487 s->secretcset[sGARROW] = secret_dlg[98].fg;
12488 s->secretflag[sGARROW] = secret_dlg[98].d2;
12489
12490 s->secretcombo[sBOMB] = secret_dlg[99].d1;
12491 s->secretcset[sBOMB] = secret_dlg[99].fg;
12492 s->secretflag[sBOMB] = secret_dlg[99].d2;
12493
12494 s->secretcombo[sSBOMB] = secret_dlg[100].d1;
12495 s->secretcset[sSBOMB] = secret_dlg[100].fg;
12496 s->secretflag[sSBOMB] = secret_dlg[100].d2;
12497
12498 for(int32_t i=0; i<3; i++)
12499 {
12500 s->secretcombo[sBRANG+i] = secret_dlg[101+i].d1;
12501 s->secretcset[sBRANG+i] = secret_dlg[101+i].fg;
12502 s->secretflag[sBRANG+i] = secret_dlg[101+i].d2;
12503 }
12504
12505 for(int32_t i=0; i<2; i++)
12506 {
12507 s->secretcombo[sWANDMAGIC+i] = secret_dlg[104+i].d1;
12508 s->secretcset[sWANDMAGIC+i] = secret_dlg[104+i].fg;
12509 s->secretflag[sWANDMAGIC+i] = secret_dlg[104+i].d2;
12510 }
12511
12512 for(int32_t i=0; i<8; i++)
12513 {
12514 s->secretcombo[sSWORD+i] = secret_dlg[106+i].d1;
12515 s->secretcset[sSWORD+i] = secret_dlg[106+i].fg;
12516 s->secretflag[sSWORD+i] = secret_dlg[106+i].d2;
12517 }
12518
12519 s->secretcombo[sSTAIRS] = secret_dlg[114].d1;
12520 s->secretcset[sSTAIRS] = secret_dlg[114].fg;
12521 s->secretflag[sSTAIRS] = secret_dlg[114].d2;
12522
12523 s->secretcombo[sREFFIREBALL] = secret_dlg[115].d1;
12524 s->secretcset[sREFFIREBALL] = secret_dlg[115].fg;
12525 s->secretflag[sREFFIREBALL] = secret_dlg[115].d2;
12526
12527 for(int32_t i=0; i<4; i++)
12528 {
12529 s->secretcombo[sHOOKSHOT+i] = secret_dlg[116+i].d1;
12530 s->secretcset[sHOOKSHOT+i] = secret_dlg[116+i].fg;
12531 s->secretflag[sHOOKSHOT+i] = secret_dlg[116+i].d2;
12532 }
12533
12534 for(int32_t i=0; i<16; i++)
12535 {
12536 s->secretcombo[sSECRET01+i] = secret_dlg[120+i].d1;
12537 s->secretcset[sSECRET01+i] = secret_dlg[120+i].fg;
12538 s->secretflag[sSECRET01+i] = secret_dlg[120+i].d2;
12539 }
12540 s->secretflag[sSECNEXT] = secret_dlg[137].d2;
12541
12542 }
12543
12544 return D_O_K;
12545 }
12546
12547 void call_undercombo_dlg(int map, int screen);
12548 int32_t onUnderCombo()
12549 {
12550 call_undercombo_dlg(Map.getCurrMap(), Map.getCurrScr());
12551 return D_O_K;
12552 }
12553
12554 static DIALOG list_dlg[] =
12555 {
12556 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
12557 12 { jwin_win_proc, 60-12, 40, 200+24, 148, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
12558 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12559 12 { jwin_list_proc, 72-12-4, 60+4, 176+24+8, 92+3, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, NULL, NULL, NULL },
12560 12 { jwin_button_proc, 90, 163, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
12561 12 { jwin_button_proc, 170, 163, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
12562 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
12563 };
12564
12565 /*
12566 typedef struct item_struct {
12567 char *s;
12568 int32_t i;
12569 } item_struct;
12570 */
12571 item_struct bii[MAXITEMS+1];
12572 int32_t bii_cnt=-1;
12573
12574 void build_bii_list(bool usenone)
12575 {
12576 int32_t start=bii_cnt=0;
12577
12578 if(usenone)
12579 {
12580 bii[0].s = (char *)"(None)";
12581 bii[0].i = -2;
12582 bii_cnt=start=1;
12583 }
12584
12585 for(int32_t i=0; i<MAXITEMS; i++)
12586 {
12587 bii[bii_cnt].s = item_string[i];
12588 bii[bii_cnt].i = i;
12589 ++bii_cnt;
12590 }
12591
12592 for(int32_t i=start; i<bii_cnt-1; i++)
12593 {
12594 for(int32_t j=i+1; j<bii_cnt; j++)
12595 {
12596 if(stricmp(bii[i].s,bii[j].s)>0 && strcmp(bii[j].s,""))
12597 {
12598 zc_swap(bii[i],bii[j]);
12599 }
12600 }
12601 }
12602 }
12603
12604 const char *itemlist_num(int32_t index, int32_t *list_size)
12605 {
12606 if(index<0)
12607 {
12608 *list_size = bii_cnt;
12609 return NULL;
12610 }
12611 static char biin_buf[64+6];
12612 if(bii[index].i < 0)
12613 return bii[index].s;
12614 sprintf(biin_buf, "%s (%03d)", bii[index].s, bii[index].i);
12615 return biin_buf;
12616 }
12617
12618 weapon_struct biw[MAXWPNS];
12619 int32_t biw_cnt=-1;
12620
12621 void build_biw_list()
12622 {
12623 int32_t start=biw_cnt=0;
12624
12625 for(int32_t i=start; i<MAXWPNS; i++)
12626 {
12627 biw[biw_cnt].s = (char *)weapon_string[i];
12628 biw[biw_cnt].i = i;
12629 ++biw_cnt;
12630 }
12631
12632 for(int32_t i=start; i<biw_cnt-1; i++)
12633 {
12634 for(int32_t j=i+1; j<biw_cnt; j++)
12635 if(stricmp(biw[i].s,biw[j].s)>0 && strcmp(biw[j].s,""))
12636 zc_swap(biw[i],biw[j]);
12637 }
12638 }
12639
12640 int32_t writeoneweapon(PACKFILE *f, int32_t index)
12641 {
12642 dword section_version=V_WEAPONS;
12643 int32_t zversion = ZELDA_VERSION;
12644 int32_t zbuild = VERSION_BUILD;
12645 int32_t iid = biw[index].i;
12646 al_trace("Writing Weapon Sprite .zwpnspr file for weapon id: %d\n", iid);
12647
12648 //section version info
12649 if(!p_iputl(zversion,f))
12650 {
12651 return 0;
12652 }
12653 if(!p_iputl(zbuild,f))
12654 {
12655 return 0;
12656 }
12657 if(!p_iputw(section_version,f))
12658 {
12659 return 0;
12660 }
12661
12662 if(!write_deprecated_section_cversion(section_version, f))
12663 {
12664 return 0;
12665 }
12666
12667 //weapon string
12668
12669 if(!pfwrite((char *)weapon_string[iid], 64, f))
12670 {
12671 return 0;
12672 }
12673
12674 if(!p_putc(wpnsbuf[iid].misc,f))
12675 {
12676 return 0;
12677 }
12678
12679 if(!p_putc(wpnsbuf[iid].csets,f))
12680 {
12681 return 0;
12682 }
12683
12684 if(!p_putc(wpnsbuf[iid].frames,f))
12685 {
12686 return 0;
12687 }
12688
12689 if(!p_putc(wpnsbuf[iid].speed,f))
12690 {
12691 return 0;
12692 }
12693
12694 if(!p_putc(wpnsbuf[iid].type,f))
12695 {
12696 return 0;
12697 }
12698
12699 if(!p_iputw(wpnsbuf[iid].script,f))
12700 {
12701 return 0;
12702 }
12703
12704 //2.55 starts here
12705 if(!p_iputl(wpnsbuf[iid].tile,f))
12706 {
12707 return 0;
12708 }
12709
12710 return 1;
12711 }
12712
12713
12714 int32_t readoneweapon(PACKFILE *f, int32_t index)
12715 {
12716 dword section_version = 0;
12717 int32_t zversion = 0;
12718 int32_t zbuild = 0;
12719 wpndata tempwpnspr;
12720 memset(&tempwpnspr, 0, sizeof(wpndata));
12721
12722
12723 //char dmapstring[64]={0};
12724 //section version info
12725 if(!p_igetl(&zversion,f))
12726 {
12727 return 0;
12728 }
12729 if(!p_igetl(&zbuild,f))
12730 {
12731 return 0;
12732 }
12733 if(!p_igetw(&section_version,f))
12734 {
12735 return 0;
12736 }
12737 if(!read_deprecated_section_cversion(f))
12738 {
12739 return 0;
12740 }
12741 al_trace("readoneweapon section_version: %d\n", section_version);
12742
12743 if ( zversion > ZELDA_VERSION )
12744 {
12745 al_trace("Cannot read .zwpnspr packfile made in ZC version (%x) in this version of ZC (%x)\n", zversion, ZELDA_VERSION);
12746 return 0;
12747 }
12748
12749 else if ( ( section_version > V_WEAPONS ) )
12750 {
12751 al_trace("Cannot read .zwpnspr packfile made using V_WEAPONS (%d)\n", section_version);
12752 return 0;
12753
12754 }
12755 else
12756 {
12757 al_trace("Reading a .zwpnspr packfile made in ZC Version: %x, Build: %d\n", zversion, zbuild);
12758 }
12759
12760 char tmp_wpn_name[64];
12761 memset(tmp_wpn_name,0,64);
12762 if(!pfread(&tmp_wpn_name, 64, f))
12763 {
12764 return 0;
12765 }
12766
12767 word oldtile = 0;
12768 if(section_version < 8)
12769 if(!p_igetw(&oldtile,f))
12770 return 0;
12771
12772 if(!p_getc(&tempwpnspr.misc,f))
12773 {
12774 return 0;
12775 }
12776
12777 if(!p_getc(&tempwpnspr.csets,f))
12778 {
12779 return 0;
12780 }
12781
12782 if(!p_getc(&tempwpnspr.frames,f))
12783 {
12784 return 0;
12785 }
12786
12787 if(!p_getc(&tempwpnspr.speed,f))
12788 {
12789 return 0;
12790 }
12791
12792 if(!p_getc(&tempwpnspr.type,f))
12793 {
12794 return 0;
12795 }
12796
12797 if(!p_igetw(&tempwpnspr.script,f))
12798 {
12799 return 0;
12800 }
12801
12802 //2.55 starts here
12803 if ( zversion >= 0x255 )
12804 {
12805 if ( section_version >= 7 )
12806 {
12807 if(!p_igetl(&tempwpnspr.tile,f))
12808 {
12809 return 0;
12810 }
12811 }
12812 }
12813 if ( zversion < 0x255 )
12814 {
12815 tempwpnspr.tile = oldtile;
12816 }
12817 ::memcpy( &(wpnsbuf[biw[index].i]),&tempwpnspr, sizeof(wpndata));
12818 ::memcpy(weapon_string[biw[index].i], tmp_wpn_name, 64);
12819
12820 return 1;
12821 }
12822
12823 static int32_t seldata_copy;
12824 static void (*seldata_paste_func)(int32_t, int32_t);
12825
12826 void seldata_rclick_func(int32_t index, int32_t x, int32_t y)
12827 {
12828 NewMenu rcmenu {
12829 { "&Copy", [&](){seldata_copy = index;} },
12830 { "Paste", "&v", [&]()
12831 {
12832 seldata_paste_func(seldata_copy, index);
12833 mark_save_dirty();
12834 }, 0, seldata_copy < 0 ? MFL_DIS : 0 },
12835 };
12836 rcmenu.pop(x, y);
12837 }
12838
12839 int32_t select_data(const char *prompt,int32_t index,const char *(proc)(int32_t,int32_t*), FONT *title_font, void (*copyFunc)(int32_t, int32_t))
12840 {
12841 if(proc==NULL)
12842 return -1;
12843
12844 list_dlg[0].dp=(void *)prompt;
12845 list_dlg[0].dp2=title_font;
12846 list_dlg[2].d1=index;
12847 ListData select_list(proc, &font);
12848 list_dlg[2].dp=(void *) &select_list;
12849
12850 large_dialog(list_dlg);
12851
12852 seldata_copy=-1;
12853 seldata_paste_func=copyFunc;
12854 if(copyFunc)
12855 {
12856 list_dlg[2].flags|=D_USER<<1;
12857 list_dlg[2].dp3=(void*)seldata_rclick_func;
12858 }
12859 else
12860 {
12861 list_dlg[2].flags&=~(D_USER<<1);
12862 list_dlg[2].dp3=0;
12863 }
12864
12865 int32_t ret=do_zqdialog(list_dlg,2);
12866
12867 if(ret==0||ret==4)
12868 {
12869 position_mouse_z(0);
12870 return -1;
12871 }
12872
12873 return list_dlg[2].d1;
12874 }
12875
12876 int32_t select_data(const char *prompt,int32_t index,const char *(proc)(int32_t,int32_t*), const char *b1, const char *b2, FONT *title_font, void (*copyFunc)(int32_t, int32_t))
12877 {
12878 if(proc==NULL)
12879 return -1;
12880
12881 list_dlg[0].dp=(void *)prompt;
12882 list_dlg[0].dp2=title_font;
12883 list_dlg[2].d1=index;
12884 ListData select_data_list(proc, &font);
12885 list_dlg[2].dp=(void *) &select_data_list;
12886 list_dlg[3].dp=(void *)b1;
12887 list_dlg[4].dp=(void *)b2;
12888
12889 large_dialog(list_dlg);
12890
12891 seldata_copy=-1;
12892 seldata_paste_func=copyFunc;
12893 if(copyFunc)
12894 {
12895 list_dlg[2].flags|=D_USER<<1;
12896 list_dlg[2].dp3=(void*)seldata_rclick_func;
12897 }
12898 else
12899 {
12900 list_dlg[2].flags&=~(D_USER<<1);
12901 list_dlg[2].dp3=0;
12902 }
12903
12904 int32_t ret = do_zqdialog(list_dlg,2);
12905 list_dlg[3].dp=(void *) "OK";
12906 list_dlg[4].dp=(void *) "Cancel";
12907
12908 if(ret==0||ret==4)
12909 {
12910 position_mouse_z(0);
12911 return -1;
12912 }
12913
12914 position_mouse_z(0);
12915 return list_dlg[2].d1;
12916 }
12917
12918 int32_t onScreenScript()
12919 {
12920 call_screendata_dialog(7);
12921 return D_O_K;
12922 }
12923
12924 int32_t onScrData()
12925 {
12926 restore_mouse();
12927 call_screendata_dialog();
12928 return D_O_K;
12929 }
12930
12931 static char number_str_buf[MIDI_TRACK_BUFFER_SIZE];
12932 int32_t number_list_size=1;
12933 bool number_list_zero=false;
12934
12935 const char *numberlist(int32_t index, int32_t *list_size)
12936 {
12937 if(index>=0)
12938 {
12939 bound(index,0,number_list_size-1);
12940 sprintf(number_str_buf,"%d",index+(number_list_zero?0:1));
12941 return number_str_buf;
12942 }
12943
12944 *list_size=number_list_size;
12945 return NULL;
12946 }
12947
12948 static char dmap_str_buf[37];
12949 int32_t dmap_list_size=MAXDMAPS;
12950 bool dmap_list_zero=true;
12951
12952 const char *dmaplist(int32_t index, int32_t *list_size)
12953 {
12954 if(index>=0)
12955 {
12956 bound(index,0,dmap_list_size-1);
12957 sprintf(dmap_str_buf,"%3d-%s",index+(dmap_list_zero?0:1), DMaps[index].name);
12958 return dmap_str_buf;
12959 }
12960
12961 *list_size=dmap_list_size;
12962 return NULL;
12963 }
12964
12965 const char *gotomaplist(int32_t index, int32_t *list_size)
12966 {
12967 if(index>=0)
12968 {
12969 bound(index,0,map_count-1);
12970 sprintf(number_str_buf,"%d",index+1);
12971 return number_str_buf;
12972 }
12973
12974 *list_size = map_count;
12975 return NULL;
12976 }
12977
12978 const char *midilist(int32_t index, int32_t *list_size)
12979 {
12980 if(index>=0)
12981
12982 {
12983 bound(index,0,MAXCUSTOMMIDIS_ZQ-1);
12984 return midi_string[index];
12985 }
12986
12987 *list_size=MAXCUSTOMMIDIS_ZQ;
12988 return NULL;
12989 }
12990
12991 const char *levelnumlist(int32_t index, int32_t *list_size)
12992 {
12993 if(index>=0)
12994 {
12995 bound(index,0,0xFFF);
12996 sprintf(number_str_buf,"%.3X - %s",index,palnames[index]);
12997 return number_str_buf;
12998 }
12999
13000 *list_size=MAXLEVELS;
13001 return NULL;
13002 }
13003
13004 static char shop_str_buf[40];
13005 int32_t shop_list_size=1;
13006
13007 const char *shoplist(int32_t index, int32_t *list_size)
13008 {
13009 if(index>=0)
13010 {
13011 bound(index,0,shop_list_size-1);
13012 sprintf(shop_str_buf,"%3d: %s",index,QMisc.shop[index].name);
13013 return shop_str_buf;
13014 }
13015
13016 *list_size=shop_list_size;
13017 return NULL;
13018 }
13019
13020 static char bottle_str_buf[40];
13021 int32_t bottle_list_size=1;
13022
13023 const char *bottlelist(int32_t index, int32_t *list_size)
13024 {
13025 if(index>=0)
13026 {
13027 bound(index,0,bottle_list_size-1);
13028 sprintf(bottle_str_buf,"%2d: %s",index+1,QMisc.bottle_types[index].name);
13029 return bottle_str_buf;
13030 }
13031
13032 *list_size=bottle_list_size;
13033 return NULL;
13034 }
13035
13036 static char bottleshop_str_buf[40];
13037 int32_t bottleshop_list_size=1;
13038
13039 const char *bottleshoplist(int32_t index, int32_t *list_size)
13040 {
13041 if(index>=0)
13042 {
13043 bound(index,0,bottleshop_list_size-1);
13044 sprintf(bottleshop_str_buf,"%3d: %s",index,QMisc.bottle_shop_types[index].name);
13045 return bottleshop_str_buf;
13046 }
13047
13048 *list_size=bottleshop_list_size;
13049 return NULL;
13050 }
13051
13052 static char info_str_buf[40];
13053 int32_t info_list_size=1;
13054
13055 const char *infolist(int32_t index, int32_t *list_size)
13056 {
13057 if(index>=0)
13058 {
13059 bound(index,0,info_list_size-1);
13060 sprintf(info_str_buf,"%3d: %s",index,QMisc.info[index].name);
13061 return info_str_buf;
13062 }
13063
13064 *list_size=info_list_size;
13065 return NULL;
13066 }
13067
13068 bool mapcount_will_affect_layers(word newmapcount)
13069 {
13070 for(int32_t i=0; i<(newmapcount)*MAPSCRS; i++)
13071 {
13072 mapscr *layerchecker=&TheMaps[i];
13073
13074 for(int32_t j=0; j<6; j++)
13075 {
13076 if(layerchecker->layermap[j]>(newmapcount))
13077 {
13078 return true;
13079 }
13080 }
13081 }
13082 return false;
13083 }
13084
13085 void update_map_count(word newmapcount)
13086 {
13087 if(map_count == newmapcount) return;
13088 mark_save_dirty();
13089 setMapCount2(newmapcount);
13090 //Prevent the nine 'last mapscreen' buttons from pointing to invlid locations
13091 //if the user reduces the mapcount. -Z ( 23rd September, 2019 )
13092 for ( int32_t q = 0; q < 9; q++ )
13093 {
13094 map_page[q].map = ( map_page[q].map > newmapcount-1 ) ? newmapcount-1 : map_page[q].map;
13095 }
13096 for(int32_t i=0; i<(newmapcount)*MAPSCRS; i++)
13097 {
13098 fix_layers(&TheMaps[i], false);
13099 }
13100
13101 refresh(rMAP+rSCRMAP+rMENU);
13102 }
13103
13104 int32_t onGotoMap()
13105 {
13106 int32_t ret = select_data("Goto Map",Map.getCurrMap(),gotomaplist,get_zc_font(font_lfont));
13107
13108 if(ret >= 0)
13109 {
13110 int32_t m=Map.getCurrMap();
13111 Map.setCurrMap(ret);
13112 }
13113
13114 refresh(rALL);
13115 return D_O_K;
13116 }
13117
13118 int32_t onFlags()
13119 {
13120 restore_mouse();
13121 int32_t ret=select_cflag("Select Combo Flag",Flag);
13122 position_mouse_z(0);
13123
13124 if(ret>=0)
13125 {
13126 Flag=ret;
13127 refresh(rMENU);
13128 doflags();
13129 }
13130
13131 return D_O_K;
13132 }
13133
13134 static DIALOG usedcombo_list_dlg[] =
13135 {
13136 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
13137 12 { jwin_win_proc, 60-12, 40, 200+24, 148, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Combos Used", NULL, NULL },
13138 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
13139 12 { jwin_textbox_proc, 72-12, 60+4, 176+24+1, 92+4, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, NULL, NULL, NULL },
13140 12 { jwin_button_proc, 130, 163, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
13141 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
13142 };
13143
13144
13145
13146 int32_t onUsedCombos()
13147 {
13148 restore_mouse();
13149 usedcombo_list_dlg[0].dp2=get_zc_font(font_lfont);
13150
13151 int32_t usedcombos[7][300][2];
13152 char combolist_text[65536];
13153 char temptext[80];
13154
13155 int32_t drawmap=Map.getCurrMap();
13156 int32_t drawscr=Map.getCurrScr();
13157 int32_t counter[7];
13158
13159 for(int32_t layer=0; layer<7; ++layer)
13160 {
13161 counter[layer]=0;
13162
13163 if(layer==0)
13164 {
13165 drawmap=Map.getCurrMap();
13166 drawscr=Map.getCurrScr();
13167 }
13168 else
13169 {
13170 drawmap=Map.CurrScr()->layermap[layer-1]-1;
13171 drawscr=Map.CurrScr()->layerscreen[layer-1];
13172 }
13173 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
13174 if(!draw_mapscr) continue;
13175
13176 usedcombos[layer][0][0]=draw_mapscr->data[0];
13177 usedcombos[layer][0][1]=1;
13178 counter[layer]=1;
13179
13180 for(int32_t i=1; i<176; ++i)
13181 {
13182 bool used=false;
13183
13184 for(int32_t j=0; j<counter[layer]; ++j)
13185 {
13186 if(usedcombos[layer][j][0]==draw_mapscr->data[i])
13187 {
13188 ++usedcombos[layer][j][1];
13189 used=true;
13190 break;
13191 }
13192 }
13193
13194 if(!used)
13195 {
13196 usedcombos[layer][counter[layer]][0]=draw_mapscr->data[i];
13197 usedcombos[layer][counter[layer]][1]=1;
13198 ++counter[layer];
13199 }
13200 }
13201
13202 for(int32_t i=0; i<counter[layer]-1; i++)
13203 {
13204 for(int32_t j=i+1; j<counter[layer]; j++)
13205 {
13206 if(usedcombos[layer][i][0]>usedcombos[layer][j][0])
13207 {
13208 zc_swap(usedcombos[layer][i][0],usedcombos[layer][j][0]);
13209 zc_swap(usedcombos[layer][i][1],usedcombos[layer][j][1]);
13210 }
13211 }
13212 }
13213 }
13214
13215 sprintf(combolist_text, " ");
13216
13217 for(int32_t layer=0; layer<7; ++layer)
13218 {
13219 if(counter[layer]>0)
13220 {
13221 if(layer>0)
13222 {
13223 strcat(combolist_text, "\n");
13224 }
13225
13226 sprintf(temptext, "Combos on layer %d\n-----------------\n", layer);
13227 strcat(combolist_text, temptext);
13228
13229 for(int32_t i=0; i<counter[layer]; i++)
13230 {
13231 if((i<counter[layer]-1) && (((usedcombos[layer][i][1]==usedcombos[layer][i+1][1]&&(usedcombos[layer][i][0]+1==usedcombos[layer][i+1][0])) && ((i==0) || ((usedcombos[layer][i][1]!=usedcombos[layer][i-1][1])||((usedcombos[layer][i][0]-1!=usedcombos[layer][i-1][0])))))))
13232 {
13233 sprintf(temptext, "%5d ", usedcombos[layer][i][0]);
13234 strcat(combolist_text, temptext);
13235 }
13236 else if(((i>0) && (((usedcombos[layer][i][1]==usedcombos[layer][i-1][1])&&((usedcombos[layer][i][0]-1==usedcombos[layer][i-1][0]))) && ((i==counter[layer]-1) || ((usedcombos[layer][i][1]!=usedcombos[layer][i+1][1])||((usedcombos[layer][i][0]+1!=usedcombos[layer][i+1][0])))))))
13237 {
13238 sprintf(temptext, "- %5d (%3d)\n", usedcombos[layer][i][0],usedcombos[layer][i][1]);
13239 strcat(combolist_text, temptext);
13240 }
13241 else if(((i==0) && ((usedcombos[layer][i][1]!=usedcombos[layer][i+1][1])||((usedcombos[layer][i][0]+1!=usedcombos[layer][i+1][0]))))||
13242 ((i==counter[layer]-1) && ((usedcombos[layer][i][1]!=usedcombos[layer][i-1][1])||((usedcombos[layer][i][0]-1!=usedcombos[layer][i-1][0]))))||
13243 ((i>0) && (i<counter[layer]-1) && ((usedcombos[layer][i][1]!=usedcombos[layer][i+1][1])||((usedcombos[layer][i][0]+1!=usedcombos[layer][i+1][0]))) && ((usedcombos[layer][i][1]!=usedcombos[layer][i-1][1])||((usedcombos[layer][i][0]-1!=usedcombos[layer][i-1][0])))))
13244 {
13245 sprintf(temptext, " %5d (%3d)\n", usedcombos[layer][i][0],usedcombos[layer][i][1]);
13246 strcat(combolist_text, temptext);
13247 }
13248 }
13249 }
13250 }
13251
13252 strcat(combolist_text, "\n");
13253 usedcombo_list_dlg[2].dp=combolist_text;
13254 usedcombo_list_dlg[2].d2=0;
13255
13256 large_dialog(usedcombo_list_dlg);
13257
13258 do_zqdialog(usedcombo_list_dlg,2);
13259 position_mouse_z(0);
13260 return D_O_K;
13261 }
13262
13263 int32_t onItem()
13264 {
13265 restore_mouse();
13266 int32_t exit_status;
13267 int32_t current_item=Map.CurrScr()->hasitem != 0 ? Map.CurrScr()->item : -1;
13268
13269 ItemListerDialog(current_item,true).show();
13270 if(current_item != lister_sel_val)
13271 {
13272 if(lister_sel_val>=0)
13273 {
13274 mark_save_dirty();
13275 Map.CurrScr()->item = lister_sel_val;
13276 Map.CurrScr()->hasitem = true;
13277 }
13278 else
13279 {
13280 mark_save_dirty();
13281 Map.CurrScr()->hasitem = false;
13282 }
13283 }
13284
13285 refresh(rMAP+rMENU);
13286 return D_O_K;
13287 }
13288
13289 void call_room_dlg(mapscr* scr);
13290 int32_t onRoom()
13291 {
13292 restore_mouse();
13293 auto* scr = Map.CurrScr();
13294 call_room_dlg(scr);
13295
13296 refresh(rMAP+rMENU);
13297 return D_O_K;
13298 }
13299
13300 int32_t onEndString()
13301 {
13302 int32_t ret=select_data("Select Ending String",QMisc.endstring,msgslist,get_zc_font(font_lfont));
13303
13304 if(ret>=0)
13305 {
13306 mark_save_dirty();
13307 QMisc.endstring=msglistcache[ret];
13308 }
13309
13310 refresh(rMENU);
13311 return D_O_K;
13312 }
13313
13314 12 static ListData levelnum_list(levelnumlist, &font);
13315
13316 static DIALOG screen_pal_dlg[] =
13317 {
13318 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
13319 12 { jwin_win_proc, 60-12, 40, 200-16, 96, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Select Palette", NULL, NULL },
13320 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
13321 12 { jwin_droplist_proc, 72-12, 84+4, 161, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, (void *) &levelnum_list, NULL, NULL },
13322 12 { jwin_button_proc, 70, 111, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
13323 12 { jwin_button_proc, 150, 111, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
13324 12 { jwin_text_proc, 72-12, 60+4, 168, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Note: This does not affect how the", NULL, NULL },
13325 12 { jwin_text_proc, 72-12, 72+4, 168, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "room will be displayed in-game!", NULL, NULL },
13326 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
13327 };
13328 // return list_dlg[2].d1;
13329
13330 int32_t onScreenPalette()
13331 {
13332 restore_mouse();
13333 screen_pal_dlg[0].dp2=get_zc_font(font_lfont);
13334 auto oldcol = screen_pal_dlg[2].d1 = Map.getcolor();
13335
13336 large_dialog(screen_pal_dlg);
13337 auto old_valid = Map.CurrScr()->valid;
13338 pause_dlg_tint(true);
13339 zq_set_screen_never_freeze(true);
13340 while(true)
13341 {
13342 auto ret = do_zqdialog(screen_pal_dlg,2);
13343 if(ret == 2)
13344 {
13345 Map.setcolor(screen_pal_dlg[2].d1);
13346 refresh(rALL);
13347 }
13348 else
13349 {
13350 if(ret == 3)
13351 {
13352 if(screen_pal_dlg[2].d1 != oldcol)
13353 mark_save_dirty();
13354 Map.setcolor(screen_pal_dlg[2].d1);
13355 }
13356 else
13357 {
13358 Map.setcolor(oldcol);
13359 Map.CurrScr()->valid = old_valid;
13360 }
13361 refresh(rALL);
13362 break;
13363 }
13364 }
13365 pause_dlg_tint(false);
13366 zq_set_screen_never_freeze(false);
13367
13368 rebuild_trans_table();
13369
13370 return D_O_K;
13371 }
13372
13373 int32_t onDecScrPal()
13374 {
13375 if(DisableLPalShortcuts)
13376 {
13377 lpal_dsa();
13378 return D_O_K;
13379 }
13380 restore_mouse();
13381 int32_t c = Map.getcolor();
13382 c = (c+511) % 512;
13383 Map.setcolor(c);
13384 refresh(rALL);
13385 mark_save_dirty();
13386 return D_O_K;
13387 }
13388
13389 int32_t onIncScrPal()
13390 {
13391 if(DisableLPalShortcuts)
13392 {
13393 lpal_dsa();
13394 return D_O_K;
13395 }
13396 restore_mouse();
13397 int32_t c = Map.getcolor();
13398 c = (c+1)%512;
13399 Map.setcolor(c);
13400 refresh(rALL);
13401 mark_save_dirty();
13402 return D_O_K;
13403 }
13404
13405 int32_t PalWrap(int32_t kX, int32_t const kLowerBound, int32_t const kUpperBound)
13406 {
13407 int32_t range_size = kUpperBound - kLowerBound + 1;
13408
13409 if (kX < kLowerBound)
13410 kX += range_size * ((kLowerBound - kX) / range_size + 1);
13411
13412 return kLowerBound + (kX - kLowerBound) % range_size;
13413 }
13414
13415 int32_t onDecScrPal16()
13416 {
13417 if(DisableLPalShortcuts)
13418 {
13419 lpal_dsa();
13420 return D_O_K;
13421 }
13422 restore_mouse();
13423 int32_t c = Map.getcolor();
13424 c = PalWrap( ( c-0x10 ), 0, 511 );
13425 Map.setcolor(c);
13426 refresh(rALL);
13427 mark_save_dirty();
13428 return D_O_K;
13429 }
13430
13431 int32_t onIncScrPal16()
13432 {
13433 if(DisableLPalShortcuts)
13434 {
13435 lpal_dsa();
13436 return D_O_K;
13437 }
13438 restore_mouse();
13439 int32_t c = Map.getcolor();
13440 c = PalWrap( ( c+0x10 ), 0, 511 );
13441 Map.setcolor(c);
13442 refresh(rALL);
13443 mark_save_dirty();
13444 return D_O_K;
13445 }
13446
13447 int32_t onZoomIn()
13448 {
13449 change_mapscr_zoom(-1);
13450 return D_O_K;
13451 }
13452
13453 int32_t onZoomOut()
13454 {
13455 change_mapscr_zoom(1);
13456 return D_O_K;
13457 }
13458
13459 int32_t d_ndroplist_proc(int32_t msg,DIALOG *d,int32_t c)
13460 {
13461 int32_t ret = jwin_droplist_proc(msg,d,c);
13462
13463 // The only place this proc is used is in the info type editor.
13464 // If it's ever used anywhere else, this will probably need to be changed.
13465 // Maybe add a flag for it or something.
13466 int32_t msgID=msg_at_pos(d->d1);
13467
13468 switch(msg)
13469 {
13470 case MSG_DRAW:
13471 case MSG_CHAR:
13472 case MSG_CLICK:
13473 textprintf_ex(screen,font,d->x - 48,d->y + 4,jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%5d",msgID);
13474 }
13475
13476 return ret;
13477 }
13478
13479 int32_t d_idroplist_proc(int32_t msg,DIALOG *d,int32_t c)
13480 {
13481 int32_t ret = jwin_droplist_proc(msg,d,c);
13482
13483 switch(msg)
13484 {
13485 case MSG_DRAW:
13486 case MSG_CHAR:
13487 case MSG_CLICK:
13488 int32_t tile = bii[d->d1].i >=0 ? itemsbuf[bii[d->d1].i].tile : 0;
13489 int32_t cset = bii[d->d1].i >=0 ? itemsbuf[bii[d->d1].i].csets&15 : 0;
13490 int32_t x = d->x + d->w + 4;
13491 int32_t y = d->y - 8;
13492 int32_t w = 32;
13493 int32_t h = 32;
13494
13495 BITMAP *buf = create_bitmap_ex(8,16,16);
13496 BITMAP *bigbmp = create_bitmap_ex(8,w,h);
13497
13498 if(buf && bigbmp)
13499 {
13500 clear_bitmap(buf);
13501
13502 if(tile)
13503 overtile16(buf, tile,0,0,cset,0);
13504
13505 stretch_blit(buf, bigbmp, 0,0, 16, 16, 0, 0, w, h);
13506 destroy_bitmap(buf);
13507 jwin_draw_frame(screen,x,y,w+4,h+4,FR_DEEP);
13508 blit(bigbmp,screen,0,0,x+2,y+2,w,h);
13509 destroy_bitmap(bigbmp);
13510 }
13511
13512 }
13513
13514 return ret;
13515 }
13516
13517 int32_t d_nidroplist_proc(int32_t msg,DIALOG *d,int32_t c)
13518 {
13519 int32_t ret = d_idroplist_proc(msg,d,c);
13520
13521 switch(msg)
13522 {
13523 case MSG_DRAW:
13524 case MSG_CHAR:
13525 case MSG_CLICK:
13526 textprintf_ex(screen,font,d->x - 48,d->y + 4,jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%5d",bii[d->d1].i);
13527 }
13528
13529 return ret;
13530 }
13531
13532 // Triforce pieces
13533 static byte triframe_points[9*4] =
13534 {
13535 0,2,2,0, 2,0,4,2, 0,2,4,2, 1,1,3,1, 2,0,2,2,
13536 1,1,1,2, 1,1,2,2, 3,1,3,2, 3,1,2,2
13537 };
13538
13539 int32_t d_tri_frame_proc(int32_t msg,DIALOG *d,int32_t c)
13540 {
13541 //these are here to bypass compiler warnings about unused arguments
13542 c=c;
13543
13544 if(msg==MSG_DRAW)
13545 {
13546 int32_t x[5],y[3];
13547
13548 x[0]=d->x;
13549 x[1]=d->x+(d->w>>2);
13550 x[2]=d->x+(d->w>>1);
13551 x[3]=d->x+(d->w>>1)+(d->w>>2);
13552 x[4]=d->x+d->w;
13553 y[0]=d->y;
13554 y[1]=d->y+(d->h>>1);
13555 y[2]=d->y+d->h;
13556
13557 byte *p = triframe_points;
13558
13559 for(int32_t i=0; i<9; i++)
13560 {
13561 line(screen,x[*p],y[*(p+1)],x[*(p+2)],y[*(p+3)],d->fg);
13562 p+=4;
13563 }
13564 }
13565
13566 return D_O_K;
13567 }
13568
13569 int32_t d_tri_edit_proc(int32_t msg,DIALOG *d,int32_t c)
13570 {
13571 jwin_button_proc(msg,d,c);
13572
13573 if(msg==MSG_CLICK)
13574 {
13575 int32_t v = getnumber("Piece Number",d->d1);
13576
13577 if(v>=0)
13578 {
13579 bound(v,1,8);
13580
13581 if(v!=d->d1)
13582 {
13583 DIALOG *tp = d - d->d2;
13584
13585 for(int32_t i=0; i<8; i++)
13586 {
13587 if(tp->d1==v)
13588 {
13589 tp->d1 = d->d1;
13590 ((char*)(tp->dp))[0] = d->d1+'0';
13591 jwin_button_proc(MSG_DRAW,tp,0);
13592 }
13593
13594 ++tp;
13595 }
13596
13597 d->d1 = v;
13598 ((char*)(d->dp))[0] = v+'0';
13599 }
13600 }
13601
13602 d->flags = 0;
13603 jwin_button_proc(MSG_DRAW,d,0);
13604 }
13605
13606 return D_O_K;
13607 }
13608
13609 static DIALOG tp_dlg[] =
13610 {
13611 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
13612 12 { jwin_win_proc, 56, 32, 208, 160, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
13613 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
13614 12 { d_tri_frame_proc, 64, 56, 192, 96, jwin_pal[jcBOXFG], jwin_pal[jcBOX], 0, 0, 0, 0, NULL, NULL, NULL },
13615 // 3
13616 12 { d_tri_edit_proc, 138, 82, 17, 17, vc(14), vc(1), 0, 0, 0, 0, (void *) "1", NULL, NULL },
13617 12 { d_tri_edit_proc, 166, 82, 17, 17, vc(14), vc(1), 0, 0, 0, 1, (void *) "2", NULL, NULL },
13618 12 { d_tri_edit_proc, 90, 130, 17, 17, vc(14), vc(1), 0, 0, 0, 2, (void *) "3", NULL, NULL },
13619 12 { d_tri_edit_proc, 214, 130, 17, 17, vc(14), vc(1), 0, 0, 0, 3, (void *) "4", NULL, NULL },
13620 // 7
13621 12 { d_tri_edit_proc, 138, 110, 17, 17, vc(14), vc(1), 0, 0, 0, 4, (void *) "5", NULL, NULL },
13622 12 { d_tri_edit_proc, 118, 130, 17, 17, vc(14), vc(1), 0, 0, 0, 5, (void *) "6", NULL, NULL },
13623 12 { d_tri_edit_proc, 166, 110, 17, 17, vc(14), vc(1), 0, 0, 0, 6, (void *) "7", NULL, NULL },
13624 12 { d_tri_edit_proc, 186, 130, 17, 17, vc(14), vc(1), 0, 0, 0, 7, (void *) "8", NULL, NULL },
13625 // 11
13626 12 { jwin_button_proc, 90, 166, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
13627 12 { jwin_button_proc, 170, 166, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
13628 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
13629 };
13630
13631 int32_t onTriPieces()
13632 {
13633 tp_dlg[0].dp2=get_zc_font(font_lfont);
13634 char temptext[8][2];
13635
13636 for(int32_t i=0; i<8; i++)
13637 {
13638 tp_dlg[i+3].d1 = QMisc.triforce[i];
13639 // ((char*)(tp_dlg[i+3].dp))[0] = QMisc.triforce[i]+'0';
13640 sprintf(temptext[i], "%d", QMisc.triforce[i]);
13641 tp_dlg[i+3].dp=temptext[i];
13642 }
13643
13644 large_dialog(tp_dlg);
13645
13646 if(do_zqdialog(tp_dlg,-1) == 11)
13647 {
13648 mark_save_dirty();
13649
13650 for(int32_t i=0; i<8; i++)
13651 QMisc.triforce[i] = tp_dlg[i+3].d1;
13652 }
13653
13654 return D_O_K;
13655 }
13656
13657 bool small_dmap=false;
13658
13659 int32_t d_hexedit_proc(int32_t msg,DIALOG *d,int32_t c)
13660 {
13661 return jwin_hexedit_proc(msg,d,c);
13662 }
13663
13664 void drawgrid(BITMAP *dest,int32_t x,int32_t y,int32_t grid,int32_t fg,int32_t bg,int32_t div)
13665 {
13666 if(div!=-1)
13667 rectfill(dest,x-1,y-1,x+63,y+3,div);
13668
13669 for(int32_t dx=0; dx<64; dx+=8)
13670 {
13671 if(grid&0x80)
13672 rectfill(dest,x+dx,y,x+dx+6,y+2,fg);
13673 else if(bg!=-1)
13674 rectfill(dest,x+dx,y,x+dx+6,y+2,bg);
13675
13676 grid<<=1;
13677 }
13678 }
13679
13680 void drawovergrid(BITMAP *dest,int32_t x,int32_t y,int32_t grid,int32_t color,int32_t div)
13681 {
13682 if(div!=-1)
13683 rectfill(dest,x-1,y-1,x+63,y+3,div);
13684
13685 for(int32_t dx=0; dx<64; dx+=4)
13686 {
13687 rectfill(dest,x+dx,y,x+dx+2,y+2,color);
13688 grid<<=1;
13689 }
13690 }
13691
13692 void drawgrid_s(BITMAP *dest,int32_t x,int32_t y,int32_t grid,int32_t fg,int32_t bg,int32_t div)
13693 {
13694 rectfill(dest,x-1,y-1,x+63,y+3,div);
13695
13696 for(int32_t dx=0; dx<64; dx+=8)
13697 {
13698 rectfill(dest,x+dx,y,x+dx+6,y+2,bg);
13699
13700 if(grid&0x80)
13701 rectfill(dest,x+dx+2,y,x+dx+4,y+2,fg);
13702
13703 grid<<=1;
13704 }
13705 }
13706
13707 void drawdmap(int32_t dmap)
13708 {
13709 int32_t c;
13710 zcolors mc=QMisc.colors;
13711
13712 switch((DMaps[dmap].type&dmfTYPE))
13713 {
13714 case dmDNGN:
13715 case dmCAVE:
13716 clear_bitmap(dmapbmp_small);
13717
13718 if(DMaps[dmap].minimap_tile[1])
13719 ;
13720 // overworld_map_tile overrides the NES minimap. dungeon_map_tile does not.
13721 else for(int32_t y=1; y<33; y+=4)
13722 drawgrid(dmapbmp_small,0,y,DMaps[dmap].grid[y>>2], DMaps[dmap].flags&dmfMINIMAPCOLORFIX ? mc.cave_fg : mc.dngn_fg, -1, -1);
13723
13724 c=DMaps[dmap].compass;
13725 // rectfill(dmapbmp,(c&15)*8+3,(c>>4)*4+1,(c&15)*8+5,(c>>4)*4+3,dvc(2*4));
13726 rectfill(dmapbmp_small,(c&15)*8+3,(c>>4)*4+1,(c&15)*8+5,(c>>4)*4+3,vc(4));
13727 c=DMaps[dmap].cont;
13728 rectfill(dmapbmp_small,(c&15)*8+3,(c>>4)*4+1,(c&15)*8+5,(c>>4)*4+3,vc(10));
13729 break;
13730
13731 case dmOVERW:
13732 clear_bitmap(dmapbmp_small);
13733
13734 if(DMaps[dmap].minimap_tile[1])
13735 ;
13736 else if(!mc.overworld_map_tile)
13737 for(int32_t y=1; y<33; y+=4)
13738 drawovergrid(dmapbmp_small,1,y,DMaps[dmap].grid[y>>2],mc.overw_bg,vc(0));
13739
13740 c=DMaps[dmap].cont;
13741 rectfill(dmapbmp_small,(c&15)*4+1,(c>>4)*4+1,(c&15)*4+3,(c>>4)*4+3,vc(10));
13742 break;
13743
13744 case dmBSOVERW:
13745 clear_bitmap(dmapbmp_small);
13746
13747 if(DMaps[dmap].minimap_tile[1])
13748 ;
13749 else if(!mc.overworld_map_tile)
13750 for(int32_t y=1; y<33; y+=4)
13751 // drawgrid_s(dmapbmp,1,y,DMaps[dmap].grid[y>>2],dvc(2*4),dvc(2*3),dvc(3+4));
13752 drawgrid_s(dmapbmp_small,0,y,DMaps[dmap].grid[y>>2],mc.bs_goal,mc.bs_dk,vc(14));
13753
13754 c=DMaps[dmap].cont;
13755 rectfill(dmapbmp_small,(c&15)*8+3,(c>>4)*4+1,(c&15)*8+5,(c>>4)*4+3,vc(10));
13756 break;
13757 }
13758 }
13759
13760 void drawdmap_screen(int32_t x, int32_t y, int32_t w, int32_t h, int32_t dmap)
13761 {
13762 BITMAP *tempbmp = create_bitmap_ex(8,w,h);
13763 clear_to_color(tempbmp, vc(0));
13764 zcolors mc=QMisc.colors;
13765
13766 // rectfill(tempbmp,x,y,x+w-1,y+h-1,vc(0));
13767
13768 if(DMaps[dmap].minimap_tile[1])
13769 {
13770 draw_block(tempbmp,0,0,DMaps[dmap].minimap_tile[1],DMaps[dmap].minimap_cset[1],5,3);
13771 }
13772 else if(((DMaps[dmap].type&dmfTYPE)==dmDNGN || (DMaps[dmap].type&dmfTYPE)==dmCAVE) && mc.dungeon_map_tile)
13773 {
13774 draw_block(tempbmp,0,0,mc.dungeon_map_tile,mc.dungeon_map_cset,5,3);
13775 }
13776 else if(((DMaps[dmap].type&dmfTYPE)==dmOVERW || (DMaps[dmap].type&dmfTYPE)==dmBSOVERW) && mc.overworld_map_tile)
13777 {
13778 draw_block(tempbmp,0,0,mc.overworld_map_tile,mc.overworld_map_cset,5,3);
13779 }
13780
13781 masked_blit(dmapbmp_small,tempbmp,0,0,8,7,65,33);
13782
13783 blit(tempbmp,screen,0,0,x,y,w,h);
13784 destroy_bitmap(tempbmp);
13785
13786 }
13787
13788 int32_t d_dropdmaplist_proc(int32_t msg,DIALOG *d,int32_t c)
13789 {
13790 if(msg==MSG_DRAW)
13791 {
13792 int32_t dmap = d->d1;
13793 int32_t *xy = (int32_t*)(d->dp3);
13794 float temp_scale = 1.5;
13795
13796 drawdmap(dmap);
13797
13798 if(xy[0]>-1000&&xy[1]>-1000)
13799 {
13800 int32_t x = d->x+int32_t((xy[0]-2)*temp_scale);
13801 int32_t y = d->y+int32_t((xy[1]-2)*temp_scale);
13802 int32_t w = 84;
13803 int32_t h = 52;
13804 jwin_draw_frame(screen,x,y,w,h,FR_DEEP);
13805 drawdmap_screen(x+2,y+2,w-4,h-4,dmap);
13806 }
13807
13808 if(xy[2]>-1000&&xy[3]>-1000)
13809 {
13810 textprintf_ex(screen,get_zc_font(font_lfont_l),d->x+int32_t((xy[2])*temp_scale),d->y+int32_t((xy[3])*temp_scale),jwin_pal[jcBOXFG],jwin_pal[jcBOX],"Map: %-3d",DMaps[d->d1].map+1);
13811 }
13812
13813 if(xy[4]>-1000&&xy[5]>-1000)
13814 {
13815 textprintf_ex(screen,get_zc_font(font_lfont_l),d->x+int32_t((xy[4])*temp_scale),d->y+int32_t((xy[5])*temp_scale),jwin_pal[jcBOXFG],jwin_pal[jcBOX],"Level: %-3d",DMaps[d->d1].level);
13816 }
13817 }
13818
13819 return jwin_droplist_proc(msg,d,c);
13820 }
13821
13822 void drawxmap(ALLEGRO_BITMAP* dest, int32_t themap, int32_t xoff, bool large, int dx, int dy)
13823 {
13824 ALLEGRO_STATE old_state;
13825 al_store_state(&old_state, ALLEGRO_STATE_TARGET_BITMAP);
13826
13827 al_set_target_bitmap(dest);
13828 al_clear_to_color(al_map_rgba(0, 0, 0, 0));
13829
13830 int32_t cols = (large ? 8 : 16);
13831 int32_t col_width = large ? 22 : 11;
13832 int32_t dot_width = (large ? 6 : 4);
13833 int32_t dot_offset = (large ? 7 : 3);
13834 int32_t l = 10;
13835
13836 for (int32_t y = 0; y < 8; y++)
13837 {
13838 // Users might have set the dmap to a map that has since been deleted.
13839 if (themap >= Map.getMapCount())
13840 break;
13841
13842 for (int32_t x = 0; x < cols; x++)
13843 {
13844 if (x + xoff < 0 || x + xoff > 15)
13845 continue;
13846
13847 const mapscr* scr = get_canonical_scr(themap, y * 16 + x + (large ? xoff : 0));
13848 if (!(scr->valid & mVALID))
13849 continue;
13850
13851 al_draw_filled_rectangle(dx + (x * col_width), dy + (y * l), dx + (x * col_width + col_width), dy + ((y * l) + l), real_lc1(scr->color));
13852 al_draw_filled_rectangle(dx + (x * col_width + dot_offset), dy + (y * l + 3), dx + (x * col_width + dot_offset + dot_width), dy + (y * l + l - 3), real_lc2(scr->color));
13853 }
13854 }
13855
13856 al_restore_state(&old_state);
13857 }
13858
13859 12 ListData dmap_list(dmaplist, &font);
13860
13861 12 static dmap copiedDMap;
13862 static byte dmapcopied = 0;
13863
13864 int32_t writesomedmaps(PACKFILE *f, int32_t first, int32_t last, int32_t max)
13865 {
13866
13867 dword section_version=V_DMAPS;
13868 int32_t zversion = ZELDA_VERSION;
13869 int32_t zbuild = VERSION_BUILD;
13870
13871 if(!p_iputl(V_ZDMAP,f))
13872 {
13873 return 0;
13874 }
13875
13876 //section version info
13877 if(!p_iputl(zversion,f))
13878 {
13879 return 0;
13880 }
13881 if(!p_iputl(zbuild,f))
13882 {
13883 return 0;
13884 }
13885 if(!p_iputw(section_version,f))
13886 {
13887 new_return(2);
13888 }
13889
13890 if(!write_deprecated_section_cversion(section_version, f))
13891 {
13892 new_return(3);
13893 }
13894 //max possible at this time
13895 if(!p_iputl(max,f))
13896 {
13897 new_return(4);
13898 }
13899 //first id written
13900 if(!p_iputl(first,f))
13901 {
13902 new_return(5);
13903 }
13904 //last id written
13905 if(!p_iputl(last,f))
13906 {
13907 new_return(6);
13908 }
13909 int32_t count = last-first;
13910 //number written
13911 if(!p_iputl(count,f))
13912 {
13913 new_return(7);
13914 }
13915
13916
13917 for ( int32_t i = first; i <= last; ++i )
13918 {
13919 if ( i > max ) break;
13920
13921 if (int ret = write_one_dmap(f, i))
13922 return ret;
13923 }
13924
13925 return 1;
13926 }
13927
13928 int32_t readsomedmaps(PACKFILE *f)
13929 {
13930 dword section_version = 0;
13931 int32_t zversion = 0;
13932 int32_t zbuild = 0;
13933 dmap tempdmap{};
13934
13935 int32_t first = 0, last = 0, max = 0, count = 0;
13936 int32_t datatype_version = 0;
13937
13938 //char dmapstring[64]={0};
13939 //section version info
13940 if(!p_igetl(&datatype_version,f))
13941 {
13942 return 0;
13943 }
13944 if ( datatype_version < 0 )
13945 {
13946 if(!p_igetl(&zversion,f))
13947 {
13948 return 0;
13949 }
13950 }
13951 else
13952 {
13953 zversion = datatype_version;
13954 }
13955 if(!p_igetl(&zbuild,f))
13956 {
13957 return 0;
13958 }
13959
13960 if(!p_igetw(&section_version,f))
13961 {
13962 return 0;
13963 }
13964
13965 if(!read_deprecated_section_cversion(f))
13966 {
13967 return 0;
13968 }
13969 if ( datatype_version < 0 )
13970 {
13971 if(!p_igetl(&max,f))
13972 {
13973 return 0;
13974 }
13975 if(!p_igetl(&first,f))
13976 {
13977 return 0;
13978 }
13979 if(!p_igetl(&last,f))
13980 {
13981 return 0;
13982 }
13983 if(!p_igetl(&count,f))
13984 {
13985 return 0;
13986 }
13987 }
13988 else
13989 {
13990 first = 0;
13991 last = 0;
13992 count = 1;
13993 max = 255;
13994 }
13995
13996
13997
13998
13999 al_trace("readsomedmaps section_version: %d\n", section_version);
14000
14001 if ( zversion > ZELDA_VERSION )
14002 {
14003 al_trace("Cannot read .zdmap packfile made in ZC version (%x) in this version of ZC (%x)\n", zversion, ZELDA_VERSION);
14004 return 0;
14005 }
14006 else if (( section_version > V_DMAPS ))
14007 {
14008 al_trace("Cannot read .zdmap packfile made using V_DMAPS (%d)\n", section_version);
14009 return 0;
14010 }
14011 else
14012 {
14013 al_trace("Reading a .zdmap packfile made in ZC Version: %x, Build: %d\n", zversion, zbuild);
14014 }
14015 //if(!pfread(&dmapstring, 64, f))
14016 //{
14017 // return 0;
14018 //}
14019 for ( int32_t i = first; i <= last; ++i )
14020 {
14021 if (int ret = read_one_dmap(f, &header, section_version, i))
14022 return ret;
14023 }
14024 return 1;
14025 }
14026
14027 int32_t onDmaps()
14028 {
14029 DMapListerDialog(0).show();
14030 return D_O_K;
14031 }
14032
14033 int32_t onMaps()
14034 {
14035 call_edit_map_settings(Map.getCurrMap());
14036 return D_O_K;
14037 }
14038
14039 int32_t onMidis()
14040 {
14041 stopMusic();
14042 MidiListerDialog().show();
14043 return D_O_K;
14044 }
14045
14046 const char *warptypelist(int32_t index, int32_t *list_size)
14047 {
14048 if(index>=0)
14049 {
14050 if(index>=MAXWARPTYPES)
14051 index=MAXWARPTYPES-1;
14052
14053 return warptype_string[index];
14054 }
14055
14056 *list_size=MAXWARPTYPES;
14057 // *list_size=6;
14058 return NULL;
14059 }
14060
14061 const char *warpeffectlist(int32_t index, int32_t *list_size)
14062 {
14063 if(index>=0)
14064 {
14065 if(index>=MAXWARPEFFECTS)
14066 index=MAXWARPEFFECTS-1;
14067
14068 return warpeffect_string[index];
14069 }
14070
14071 *list_size=MAXWARPEFFECTS;
14072 return NULL;
14073 }
14074
14075 static int32_t warp1_list[] =
14076 {
14077 2,3,4,5,6,7,8,9,10,11,12,13,53,54,63,67,-1
14078 };
14079
14080 static int32_t warp2_list[] =
14081 {
14082 17,18,19,20,21,22,23,24,25,26,27,28,55,56,64,68,-1
14083 };
14084
14085 static int32_t warp3_list[] =
14086 {
14087 29,30,31,32,33,34,35,36,37,38,39,40,57,58,65,69,-1
14088 };
14089
14090 static int32_t warp4_list[] =
14091 {
14092 41,42,43,44,45,46,47,48,49,50,51,52,59,60,66,70,-1
14093 };
14094
14095 static TABPANEL warp_tabs[] =
14096 {
14097 // (text)
14098 { (char *)"A", D_SELECTED, warp1_list, 0, NULL },
14099 { (char *)"B", 0, warp2_list, 0, NULL },
14100 { (char *)"C", 0, warp3_list, 0, NULL },
14101 { (char *)"D", 0, warp4_list, 0, NULL },
14102 { NULL, 0, NULL, 0, NULL }
14103 };
14104
14105 int32_t onTileWarpIndex(int32_t index)
14106 {
14107 int32_t i=-1;
14108
14109 while(warp_tabs[++i].text != NULL)
14110 warp_tabs[i].flags = (i==index ? D_SELECTED : 0);
14111
14112 onTileWarp();
14113 return D_O_K;
14114 }
14115
14116 static char warpr_buf[10];
14117 const char *warprlist(int32_t index, int32_t *list_size)
14118 {
14119 if(index>=0)
14120 {
14121 bound(index,0,3);
14122 sprintf(warpr_buf,"%c",index+0x41);
14123 return warpr_buf;
14124 }
14125
14126 *list_size=4;
14127 return NULL;
14128 }
14129
14130 int32_t d_wflag_proc(int32_t msg,DIALOG *d,int32_t c);
14131
14132 12 static ListData warp_dlg_list(warptypelist, &font);
14133 12 static ListData warp_ret_list(warprlist, &font);
14134
14135 int32_t d_warpdestscrsel_proc(int32_t msg,DIALOG *d,int32_t c)
14136 {
14137 if(msg == MSG_START)
14138 {
14139 d->d1 = -1; //cached val
14140 d->d2 = -1; //cached dmap
14141 d->fg = 0; //cached 'force_16'
14142 }
14143 char* buf = (char*)d->dp;
14144 vector<DIALOG*>* dlgs = (vector<DIALOG*>*)d->dp2;
14145 int* dmap_ptr = (int*) d->dp3;
14146 if(!(buf && dmap_ptr))
14147 return D_O_K;
14148 bool is_overworld = ((DMaps[*dmap_ptr].type&dmfTYPE)==dmOVERW);
14149 int scrw = is_overworld ? 16 : 8, scrh = 9;
14150 const int max = 0x87;
14151 int bufval = zc_xtoi(buf);
14152 int val = vbound(bufval,0,max);
14153 auto& dm = DMaps[*dmap_ptr];
14154 auto val_offset = dm.xoff < 0 ? -dm.xoff : 0;
14155 bool force_16 = d->fg;
14156 if(!is_overworld)
14157 {
14158 if((val&0xF) >= 0x8)
14159 force_16 = true;
14160 else if((val&0xF) < val_offset && (val&0xF0) < 0x80)
14161 force_16 = true;
14162 }
14163 if(force_16) //can't bound, some quests need to warp out of bounds... -Em
14164 {
14165 scrw = 16; //just force show the larger grid instead
14166 val_offset = 0;
14167 }
14168
14169 int xscl = d->w/scrw;
14170 int yscl = d->h/scrh;
14171
14172 int ret = D_O_K;
14173 bool redraw = false;
14174 if(d->d1 != val)
14175 {
14176 redraw = true;
14177 d->d1 = val;
14178 }
14179 if(bufval != val)
14180 {
14181 redraw = true;
14182 sprintf(buf, "%X", val);
14183 }
14184 if(d->d2 != *dmap_ptr)
14185 {
14186 redraw = true;
14187 d->d2 = *dmap_ptr;
14188 }
14189 switch(msg)
14190 {
14191 case MSG_WANTFOCUS:
14192 ret = D_WANTFOCUS;
14193 break;
14194 case MSG_CLICK:
14195 {
14196 d->fg = force_16 ? 1 : 0;
14197 bool redraw2 = false;
14198 while(gui_mouse_b())
14199 {
14200 if(redraw2)
14201 {
14202 broadcast_dialog_message(MSG_DRAW, 0);
14203 redraw2 = false;
14204 }
14205 if(!d->fg && (gui_mouse_b()&2))
14206 {
14207 scrw = 16;
14208 xscl = d->w/scrw;
14209 yscl = d->h/scrh;
14210 val_offset = 0;
14211 d->fg = 1;
14212 redraw2 = true;
14213 }
14214 custom_vsync();
14215 if(!mouse_in_rect(d->x,d->y,d->w,d->h))
14216 continue;
14217 int mx = gui_mouse_x()-d->x, my = gui_mouse_y()-d->y;
14218 int y = vbound(my/yscl,0,scrh-1);
14219 auto offs = y==8 ? 0 : val_offset;
14220 int x = vbound(mx/xscl,offs,scrw-1);
14221 auto val2 = (y*16)+x;
14222 if(val2 > max) //out of bounds in the bottom-right
14223 continue;
14224 val = val2;
14225 if(d->d1 != val)
14226 {
14227 d->d1 = val;
14228 sprintf(buf, "%02X", val);
14229 redraw2 = true;
14230 }
14231 }
14232 redraw = true;
14233 d->fg = 0;
14234 break;
14235 }
14236 case MSG_DRAW:
14237 {
14238 rectfill(screen,d->x,d->y,d->x+d->w-1,d->y+d->h-1,jwin_pal[jcBOX]);
14239 jwin_draw_frame(screen, d->x-2, d->y-2, d->w+4, d->h+4, FR_MENU);
14240 for(int yind = 0; yind < scrh; ++yind)
14241 {
14242 auto gr = (yind < 8 ? dm.grid[yind] : 0);
14243 for(int xind = (yind == 8 ? 0 : val_offset); xind < scrw; ++xind)
14244 {
14245 int screen_index = xind+(yind*16);
14246 if(screen_index > max)
14247 continue;
14248 int fr = FR_MENU;
14249 if(screen_index == d->d1)
14250 fr = FR_GREEN;
14251 else if(!is_overworld && xind < 8 && (gr&(1<<(8-xind-1))))
14252 fr = FR_MENU_INV;
14253 jwin_draw_frame(screen, d->x+(xind*xscl), d->y+(yind*yscl), xscl, yscl, fr);
14254 }
14255 }
14256 break;
14257 }
14258 case MSG_XCHAR:
14259 {
14260 bool on_80 = (val&0xF0) == 0x80;
14261 switch(c>>8)
14262 {
14263 case KEY_UP:
14264 if((val&0xF0) && !(val_offset && on_80 && (val&0xF) < val_offset))
14265 {
14266 val -= 0x10;
14267 redraw = true;
14268 }
14269 ret |= D_USED_CHAR;
14270 break;
14271 case KEY_DOWN:
14272 if((val&0xF0) < ((val&0xF) < 0x8 ? 0x80 : 0x70))
14273 {
14274 val += 0x10;
14275 redraw = true;
14276 }
14277 ret |= D_USED_CHAR;
14278 break;
14279 case KEY_LEFT:
14280 if((val&0xF) > (on_80 ? 0 : val_offset))
14281 {
14282 --val;
14283 redraw = true;
14284 }
14285 ret |= D_USED_CHAR;
14286 break;
14287 case KEY_RIGHT:
14288 if((val&0xF) < scrw-1 && val < 0x87)
14289 {
14290 ++val;
14291 redraw = true;
14292 }
14293 ret |= D_USED_CHAR;
14294 break;
14295 }
14296 if(redraw)
14297 sprintf(buf, "%02X", val);
14298 break;
14299 }
14300 }
14301 if(redraw)
14302 {
14303 if(msg == MSG_IDLE)
14304 broadcast_dialog_message(MSG_DRAW,0);
14305 else
14306 {
14307 d->d1 = d->d2 = -1;
14308 object_message(d,MSG_IDLE,0);
14309 }
14310 }
14311
14312 return ret;
14313 }
14314
14315 int32_t tilewarpdmapxy[6] = {170,38,170,18,170,27};
14316 static DIALOG tilewarp_dlg[] =
14317 {
14318 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
14319 12 { jwin_win_proc, 0, 0, 302, 178, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
14320 12 { jwin_rtext_proc, 89, 43, 40, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Type:", NULL, NULL },
14321 12 { jwin_rtext_proc, 57, 62, 40, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
14322 12 { jwin_rtext_proc, 57, 80, 64, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Screen: 0x", NULL, NULL },
14323 12 { jwin_droplist_proc, 91, 38, 193, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &warp_dlg_list, NULL, NULL },
14324 //5
14325 12 { d_dropdmaplist_proc, 59, 57, 225, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &dmap_list, NULL, tilewarpdmapxy },
14326 12 { jwin_hexedit_proc, 59, 76, 24, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
14327 12 { jwin_button_proc, 61, 152, 41, 21, vc(14), vc(1), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
14328 12 { jwin_button_proc, 121, 152, 41, 21, vc(14), vc(1), 'g', D_EXIT, 0, 0, (void *) "&Go", NULL, NULL },
14329 12 { jwin_button_proc, 181, 152, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
14330 //10
14331 12 { jwin_rtext_proc, 82, 95, 100, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Use Warp Return:", NULL, NULL },
14332 12 { jwin_droplist_proc, 10, 105, 72, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &warp_ret_list, NULL, NULL },
14333 12 { jwin_check_proc, 10, 125, 129, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Combos Carry Over", NULL, NULL },
14334 12 { d_warpdestscrsel_proc, 90, 76, 8*16, 8*9, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
14335 12 { jwin_button_proc, 59, 21, 50, 14, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "A", NULL, NULL },
14336 //15
14337 12 { jwin_button_proc, 109, 21, 50, 14, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "B", NULL, NULL },
14338 12 { jwin_button_proc, 159, 21, 50, 14, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "C", NULL, NULL },
14339 12 { jwin_button_proc, 209, 21, 50, 14, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "D", NULL, NULL },
14340 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
14341 };
14342
14343 int32_t sidewarpdmapxy[6] = {170,38,170,18,170,27};
14344 static DIALOG sidewarp_dlg[] =
14345 {
14346 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
14347 12 { jwin_win_proc, 0, 0, 302, 178, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
14348 12 { jwin_rtext_proc, 89, 43, 40, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Type:", NULL, NULL },
14349 12 { jwin_rtext_proc, 57, 62, 40, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
14350 12 { jwin_rtext_proc, 57, 80, 64, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Screen: 0x", NULL, NULL },
14351 12 { jwin_droplist_proc, 91, 38, 193, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &warp_dlg_list, NULL, NULL },
14352 //5
14353 12 { d_dropdmaplist_proc, 59, 57, 225, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &dmap_list, NULL, tilewarpdmapxy },
14354 12 { jwin_hexedit_proc, 59, 76, 24, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
14355 12 { jwin_button_proc, 61, 152, 41, 21, vc(14), vc(1), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
14356 12 { jwin_button_proc, 121, 152, 41, 21, vc(14), vc(1), 'g', D_EXIT, 0, 0, (void *) "&Go", NULL, NULL },
14357 12 { jwin_button_proc, 181, 152, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
14358 //10
14359 12 { jwin_rtext_proc, 82, 95, 100, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Use Warp Return:", NULL, NULL },
14360 12 { jwin_droplist_proc, 10, 105, 72, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &warp_ret_list, NULL, NULL },
14361 12 { jwin_check_proc, 10, 125, 129, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Combos Carry Over", NULL, NULL },
14362 12 { d_warpdestscrsel_proc, 90, 76, 8*16, 8*9, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
14363 12 { jwin_button_proc, 59, 21, 50, 14, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "A", NULL, NULL },
14364 //15
14365 12 { jwin_button_proc, 109, 21, 50, 14, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "B", NULL, NULL },
14366 12 { jwin_button_proc, 159, 21, 50, 14, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "C", NULL, NULL },
14367 12 { jwin_button_proc, 209, 21, 50, 14, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "D", NULL, NULL },
14368 // 18
14369 12 { d_wflag_proc, 18, 17, 15, 8, vc(4), vc(0), 0, 0, 1, 0, NULL, NULL, NULL },
14370 12 { d_wflag_proc, 18, 47, 15, 8, vc(4), vc(0), 0, 0, 1, 0, NULL, NULL, NULL },
14371 // 20
14372 12 { d_wflag_proc, 8, 27, 8, 15, vc(4), vc(0), 0, 0, 1, 0, NULL, NULL, NULL },
14373 12 { d_wflag_proc, 37, 27, 8, 15, vc(4), vc(0), 0, 0, 1, 0, NULL, NULL, NULL },
14374
14375 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
14376 };
14377
14378 int32_t warpringxy[6] = {170,38,170,18,170,27};
14379 static DIALOG warpring_warp_dlg[] =
14380 {
14381 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
14382 12 { jwin_win_proc, 0, 0, 302, 145, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
14383 12 { jwin_rtext_proc, 57, 25, 40, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
14384 12 { jwin_rtext_proc, 57, 46, 64, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Screen: 0x", NULL, NULL },
14385 12 { d_dropdmaplist_proc, 59, 19, 225, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &dmap_list, NULL, warpringxy },
14386 12 { jwin_hexedit_proc, 59, 39, 24, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
14387 // 5
14388 12 { jwin_button_proc, 61, 115, 41, 21, vc(14), vc(1), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
14389 12 { jwin_button_proc, 121, 115, 41, 21, vc(14), vc(1), 'g', D_EXIT, 0, 0, (void *) "&Go", NULL, NULL },
14390 12 { jwin_button_proc, 181, 115, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
14391 12 { d_warpdestscrsel_proc, 90, 39, 8*16, 8*9, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
14392
14393 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
14394 };
14395
14396 // Side warp flag procedure
14397 int32_t d_wflag_proc(int32_t msg,DIALOG *d,int32_t)
14398 {
14399 int32_t ret = D_O_K;
14400 switch(msg)
14401 {
14402 case MSG_DRAW:
14403 {
14404 int32_t c2=(d->flags&D_SELECTED)?d->fg:d->bg;
14405
14406 if(d->d1==1)
14407 {
14408 jwin_draw_frame(screen,d->x,d->y,d->w,d->h, FR_DEEP);
14409 rectfill(screen,d->x+2, d->y+2, d->x+d->w-3, d->y+d->h-3,c2);
14410
14411 if(d->flags&D_SELECTED)
14412 {
14413 int32_t e=d->d2&3;
14414
14415 if(d->w>d->h)
14416 textprintf_centre_ex(screen,get_zc_font(font_lfont_l), d->x+(d->w/2),d->y,jwin_pal[jcBOXFG],-1,"%c",e+0x41);
14417 else
14418 textprintf_centre_ex(screen,get_zc_font(font_lfont_l), d->x+(d->w/2),d->y+(d->h/2)-4,jwin_pal[jcBOXFG],-1,"%c",e+0x41);
14419 }
14420
14421 }
14422 else
14423 {
14424 rectfill(screen,d->x, d->y, d->x+d->w-1, d->y+d->h-1,c2);
14425 }
14426 }
14427 break;
14428
14429 case MSG_CLICK:
14430 {
14431 if(d->flags & D_DISABLED)
14432 return D_O_K;
14433 bool rclick = gui_mouse_b() & 2;
14434 if(d->d1==1)
14435 {
14436 if(!(d->flags&D_SELECTED))
14437 {
14438 d->flags |= D_SELECTED;
14439 d->d2 &= 0x80;
14440 if (rclick)
14441 d->d2 |= 3;
14442 }
14443 else
14444 {
14445 if((d->d2&3) == (rclick?0:3))
14446 {
14447 d->flags ^= D_SELECTED;
14448 d->d2 &= 0x80;
14449 }
14450 else
14451 {
14452 int32_t f = d->d2&3;
14453 d->d2 &= 0x80;
14454 f += rclick ? -1 : 1;
14455 d->d2 |= f;
14456 }
14457 }
14458 }
14459 else
14460 {
14461 d->flags^=D_SELECTED;
14462 }
14463
14464 int32_t c2=(d->flags&D_SELECTED)?d->fg:d->bg;
14465
14466 if(d->d1==1)
14467 {
14468 jwin_draw_frame(screen,d->x,d->y,d->w,d->h, FR_DEEP);
14469 rectfill(screen,d->x+2, d->y+2, d->x+d->w-3, d->y+d->h-3,c2);
14470
14471 if(d->flags&D_SELECTED)
14472 {
14473 int32_t e=d->d2&3;
14474
14475 if(d->w>d->h)
14476 textprintf_centre_ex(screen,get_zc_font(font_lfont_l),d->x+(d->w/2),d->y,jwin_pal[jcBOXFG],-1,"%c",e+0x41);
14477 else
14478 textprintf_centre_ex(screen,get_zc_font(font_lfont_l),d->x+(d->w/2),d->y+(d->h/2)-4,jwin_pal[jcBOXFG],-1,"%c",e+0x41);
14479 }
14480 }
14481 else
14482 {
14483 rectfill(screen,d->x, d->y, d->x+d->w-1, d->y+d->h-1,c2);
14484 }
14485
14486
14487 while(gui_mouse_b())
14488 {
14489 /* do nothing */
14490 rest(1);
14491 }
14492 ret = D_REDRAWME;
14493 }
14494 break;
14495 }
14496
14497 return ret;
14498 }
14499
14500 int32_t d_dmapscrsel_proc(int32_t msg,DIALOG *d,int32_t c)
14501 {
14502 //these are here to bypass compiler warnings about unused arguments
14503 c=c;
14504
14505 int32_t ret = D_O_K;
14506
14507 switch(msg)
14508 {
14509 case MSG_CLICK:
14510 sprintf((char*)((d+2)->dp),"%X%X",vbound((gui_mouse_y()-d->y)/4,0,7),vbound((gui_mouse_x()-d->x)/(((DMaps[(d-1)->d1].type&dmfTYPE)==1)?4:8),0,(((DMaps[(d-1)->d1].type&dmfTYPE)==1)?15:7)));
14511 object_message(d+2, MSG_DRAW, 0);
14512 break;
14513 }
14514
14515 return ret;
14516 }
14517
14518 int32_t warpdestsel_x=-1;
14519 int32_t warpdestsel_y=-1;
14520 int32_t warpdestmap=-1;
14521 int32_t warpdestscr=-1;
14522
14523 int32_t jwin_minibutton_proc(int32_t msg,DIALOG *d,int32_t c)
14524 {
14525 switch(msg)
14526 {
14527 case MSG_DRAW:
14528 jwin_draw_text_button(screen, d->x, d->y, d->w, d->h, (char*)d->dp, d->flags, false);
14529 return D_O_K;
14530 break;
14531 }
14532
14533 return jwin_button_proc(msg,d,c);
14534 }
14535
14536 int32_t d_triggerbutton_proc(int32_t msg,DIALOG *d,int32_t c)
14537 {
14538 static BITMAP *dummy=create_bitmap_ex(8, 1, 1);
14539
14540 switch(msg)
14541 {
14542 case MSG_START:
14543 d->w=gui_textout_ln(dummy, font, (uint8_t *)d->dp, 0, 0, jwin_pal[jcMEDDARK], -1, 0)+4;
14544 d->h=text_height(font)+5;
14545 break;
14546
14547 case MSG_GOTFOCUS:
14548 d->flags&=~D_GOTFOCUS;
14549 break;
14550
14551 }
14552
14553 return jwin_minibutton_proc(msg,d,c);
14554 }
14555
14556 int32_t d_alltriggerbutton_proc(int32_t msg,DIALOG *d,int32_t c)
14557 {
14558 DIALOG *temp_d;
14559 int32_t ret=d_triggerbutton_proc(msg,d,c);
14560
14561 switch(msg)
14562 {
14563 case MSG_CLICK:
14564 temp_d=d-1;
14565
14566 while(temp_d->proc==d_triggerbutton_proc)
14567 {
14568 temp_d->flags&=~D_SELECTED;
14569 temp_d->flags|=D_DIRTY;
14570
14571 if(d->flags&D_SELECTED)
14572 {
14573 temp_d->flags|=D_SELECTED;
14574 }
14575
14576 --temp_d;
14577 }
14578
14579 break;
14580 }
14581
14582 return ret;
14583 }
14584
14585 int32_t d_ticsedit_proc(int32_t msg,DIALOG *d,int32_t c)
14586 {
14587 int32_t ret = jwin_edit_proc(msg,d,c);
14588
14589 if(msg==MSG_DRAW)
14590 {
14591 int32_t tics=vbound(atoi((char*)d->dp),0,65535);
14592 sprintf((char*)(d+1)->dp,"%s %s",ticksstr(tics),tics==0?"(No Timed Warp)":" ");
14593 object_message(d+1,MSG_DRAW,c);
14594 }
14595
14596 return ret;
14597 }
14598
14599 12 static ListData warp_effect_list(warpeffectlist,&font);
14600
14601 struct tw_data
14602 {
14603 int twscr[4], twtype[4], twdmap[4], wret[4];
14604 byte oflags;
14605 optional<uint> loaded;
14606
14607 tw_data(mapscr* scr) {load_scr(scr);}
14608 void load_scr(mapscr* scr)
14609 {
14610 oflags = scr->tilewarpoverlayflags;
14611 for(int q = 0; q < 4; ++q)
14612 {
14613 twscr[q] = scr->tilewarpscr[q];
14614 twtype[q] = scr->tilewarptype[q];
14615 twdmap[q] = scr->tilewarpdmap[q];
14616 wret[q] = (scr->warpreturnc >> (2*q))&3;
14617 }
14618 loaded.reset();
14619 }
14620 void save_scr(mapscr* scr)
14621 {
14622 mark_save_dirty();
14623 scr->tilewarpoverlayflags = oflags;
14624 scr->warpreturnc = scr->warpreturnc & 0xFF00;
14625 for(int q = 0; q < 4; ++q)
14626 {
14627 scr->tilewarpscr[q] = twscr[q];
14628 scr->tilewarptype[q] = twtype[q];
14629 scr->tilewarpdmap[q] = twdmap[q];
14630 scr->warpreturnc |= wret[q] << (2*q);
14631 }
14632 }
14633
14634 void load(uint ind)
14635 {
14636 if(ind >= 4) return;
14637 loaded = ind;
14638 tilewarp_dlg[4].d1 = twtype[ind];
14639 tilewarp_dlg[5].d1 = twdmap[ind];
14640 char* buf = (char*)tilewarp_dlg[6].dp;
14641 sprintf(buf,"%02X",twscr[ind]);
14642 tilewarp_dlg[11].d1 = wret[ind];
14643 SETFLAG(tilewarp_dlg[12].flags, D_SELECTED, get_bit(&oflags,ind));
14644 for(int q = 0; q < 4; ++q)
14645 SETFLAG(tilewarp_dlg[14+q].flags,(D_SELECTED|D_DISABLED),q==ind);
14646 }
14647 void save(uint ind)
14648 {
14649 if(ind >= 4) return;
14650 twtype[ind] = tilewarp_dlg[4].d1;
14651 twdmap[ind] = tilewarp_dlg[5].d1;
14652 char* buf = (char*)tilewarp_dlg[6].dp;
14653 twscr[ind] = vbound(zc_xtoi(buf),0x00,0x87);
14654 wret[ind] = tilewarp_dlg[11].d1;
14655 set_bit(&oflags, ind, tilewarp_dlg[12].flags & D_SELECTED);
14656 }
14657 void save()
14658 {
14659 if(loaded)
14660 save(*loaded);
14661 }
14662 void swap(uint ind)
14663 {
14664 if(ind >= 4) return;
14665 if(loaded)
14666 {
14667 save(*loaded);
14668 if(*loaded == ind)
14669 return;
14670 }
14671 load(ind);
14672 }
14673 };
14674 int32_t onTileWarp()
14675 {
14676 restore_mouse();
14677 tilewarp_dlg[0].dp=(void *) "Tile Warp";
14678 tilewarp_dlg[0].dp2=get_zc_font(font_lfont);
14679
14680 mapscr* mptr = Map.CurrScr();
14681 char buf[10];
14682 tilewarp_dlg[6].dp=buf;
14683 tilewarp_dlg[13].dp = buf;
14684 tilewarp_dlg[13].dp3 = &tilewarp_dlg[5].d1;
14685
14686 vector<DIALOG*> dlgs;
14687 dlgs.push_back(&tilewarp_dlg[5]);
14688 dlgs.push_back(&tilewarp_dlg[6]);
14689 tilewarp_dlg[13].dp2 = &dlgs;
14690
14691 tw_data data(mptr);
14692 data.load(0);
14693
14694 dmap_list_size=MAXDMAPS;
14695 dmap_list_zero=true;
14696
14697 large_dialog(tilewarp_dlg);
14698
14699 bool running = true;
14700 int ret;
14701 do
14702 {
14703 ret = do_zqdialog(tilewarp_dlg,-1);
14704 switch(ret)
14705 {
14706 // OK, GO
14707 case 7: case 8:
14708 running = false;
14709 data.save();
14710 data.save_scr(mptr);
14711 refresh(rMENU);
14712 break;
14713 //Cancel
14714 case 9:
14715 running = false;
14716 break;
14717 //A,B,C,D
14718 case 14: case 15: case 16: case 17:
14719 data.swap(ret-14);
14720 break;
14721 }
14722 }
14723 while(running);
14724
14725 if(ret==8) //GO
14726 {
14727 int32_t index = *data.loaded;
14728
14729 FlashWarpSquare = -1;
14730 int32_t tm = Map.getCurrMap();
14731 int32_t ts = Map.getCurrScr();
14732 int32_t thistype = mptr->tilewarptype[index];
14733 Map.dowarp(0,index);
14734
14735 if((ts!=Map.getCurrScr() || tm!=Map.getCurrMap()) && thistype != wtCAVE && thistype != wtSCROLL)
14736 {
14737 FlashWarpSquare = (TheMaps[tm*MAPSCRS+ts].warpreturnc>>(index*2))&3;
14738 FlashWarpClk = 32;
14739 }
14740
14741 refresh(rALL);
14742 }
14743
14744 return D_O_K;
14745 }
14746
14747 struct sw_data
14748 {
14749 int swscr[4], swtype[4], swdmap[4], wret[4];
14750 byte oflags;
14751 optional<uint> loaded;
14752
14753 sw_data(mapscr* scr) {load_scr(scr);}
14754 void load_scr(mapscr* scr)
14755 {
14756 oflags = scr->sidewarpoverlayflags;
14757 for(int q = 0; q < 4; ++q)
14758 {
14759 swscr[q] = scr->sidewarpscr[q];
14760 swtype[q] = scr->sidewarptype[q];
14761 swdmap[q] = scr->sidewarpdmap[q];
14762 wret[q] = (scr->warpreturnc >> (2*(q+4)))&3;
14763 }
14764 loaded.reset();
14765
14766 for(int32_t i=0; i<4; i++)
14767 {
14768 sidewarp_dlg[18+i].d2 = 0x80;
14769 if(scr->flags2&(1<<i))
14770 {
14771 sidewarp_dlg[18+i].flags = D_SELECTED ;
14772 sidewarp_dlg[18+i].d2 |= (scr->sidewarpindex>>(2*i))&3;
14773 }
14774 else
14775 {
14776 sidewarp_dlg[18+i].flags = 0;
14777 }
14778 }
14779 }
14780 void save_scr(mapscr* scr)
14781 {
14782 mark_save_dirty();
14783 scr->sidewarpoverlayflags = oflags;
14784 scr->warpreturnc = scr->warpreturnc & 0x00FF;
14785 for(int q = 0; q < 4; ++q)
14786 {
14787 scr->sidewarpscr[q] = swscr[q];
14788 scr->sidewarptype[q] = swtype[q];
14789 scr->sidewarpdmap[q] = swdmap[q];
14790 scr->warpreturnc |= wret[q] << (2*(q+4));
14791 }
14792
14793 scr->flags2 &= ~0xF;
14794 scr->sidewarpindex = 0;
14795 for(int32_t i=0; i<4; i++)
14796 {
14797 if(sidewarp_dlg[18+i].flags & D_SELECTED)
14798 scr->flags2 |= 1<<i;
14799 scr->sidewarpindex |= (sidewarp_dlg[18+i].d2&3) << (i*2);
14800 }
14801 }
14802
14803 void load(uint ind)
14804 {
14805 if(ind >= 4) return;
14806 loaded = ind;
14807 sidewarp_dlg[4].d1 = swtype[ind];
14808 sidewarp_dlg[5].d1 = swdmap[ind];
14809 char* buf = (char*)sidewarp_dlg[6].dp;
14810 sprintf(buf,"%02X",swscr[ind]);
14811 sidewarp_dlg[11].d1 = wret[ind];
14812 SETFLAG(sidewarp_dlg[12].flags, D_SELECTED, get_bit(&oflags,ind));
14813 for(int q = 0; q < 4; ++q)
14814 SETFLAG(sidewarp_dlg[14+q].flags,(D_SELECTED|D_DISABLED),q==ind);
14815 }
14816 void save(uint ind)
14817 {
14818 if(ind >= 4) return;
14819 swtype[ind] = sidewarp_dlg[4].d1;
14820 swdmap[ind] = sidewarp_dlg[5].d1;
14821 char* buf = (char*)sidewarp_dlg[6].dp;
14822 swscr[ind] = vbound(zc_xtoi(buf),0x00,0x87);
14823 wret[ind] = sidewarp_dlg[11].d1;
14824 set_bit(&oflags, ind, sidewarp_dlg[12].flags & D_SELECTED);
14825 }
14826 void save()
14827 {
14828 if(loaded)
14829 save(*loaded);
14830 }
14831 void swap(uint ind)
14832 {
14833 if(ind >= 4) return;
14834 if(loaded)
14835 {
14836 save(*loaded);
14837 if(*loaded == ind)
14838 return;
14839 }
14840 load(ind);
14841 }
14842 };
14843 int32_t onSideWarp()
14844 {
14845 restore_mouse();
14846 sidewarp_dlg[0].dp=(void *) "Side Warp";
14847 sidewarp_dlg[0].dp2=get_zc_font(font_lfont);
14848
14849 mapscr* mptr = Map.CurrScr();
14850 char buf[10];
14851 sidewarp_dlg[6].dp=buf;
14852 sidewarp_dlg[13].dp = buf;
14853 sidewarp_dlg[13].dp3 = &sidewarp_dlg[5].d1;
14854
14855 vector<DIALOG*> dlgs;
14856 dlgs.push_back(&sidewarp_dlg[5]);
14857 dlgs.push_back(&sidewarp_dlg[6]);
14858 sidewarp_dlg[13].dp2 = &dlgs;
14859
14860 sw_data data(mptr);
14861 data.load(0);
14862
14863 dmap_list_size=MAXDMAPS;
14864 dmap_list_zero=true;
14865
14866 large_dialog(sidewarp_dlg);
14867
14868 bool running = true;
14869 int ret;
14870 do
14871 {
14872 ret = do_zqdialog(sidewarp_dlg,-1);
14873 switch(ret)
14874 {
14875 // OK, GO
14876 case 7: case 8:
14877 running = false;
14878 data.save();
14879 data.save_scr(mptr);
14880 refresh(rMENU);
14881 break;
14882 //Cancel
14883 case 9:
14884 running = false;
14885 break;
14886 //A,B,C,D
14887 case 14: case 15: case 16: case 17:
14888 data.swap(ret-14);
14889 break;
14890 }
14891 }
14892 while(running);
14893
14894 if(ret==8) //GO
14895 {
14896 int32_t index = *data.loaded;
14897
14898 FlashWarpSquare = -1;
14899 int32_t tm = Map.getCurrMap();
14900 int32_t ts = Map.getCurrScr();
14901
14902 int32_t thistype = mptr->sidewarptype[index];
14903 Map.dowarp(1,index);
14904
14905 if((ts!=Map.getCurrScr() || tm!=Map.getCurrMap()) && thistype != wtSCROLL)
14906 {
14907 FlashWarpSquare = (TheMaps[tm*MAPSCRS+ts].warpreturnc>>(8+index*2))&3;
14908 FlashWarpClk = 0x20;
14909 }
14910
14911 refresh(rALL);
14912 }
14913
14914 return D_O_K;
14915 }
14916
14917
14918
14919 const char *dirlist(int32_t index, int32_t *list_size)
14920 {
14921 if(index>=0)
14922 {
14923 if(index>3)
14924 index=3;
14925
14926 return mazedirstr[index];
14927 }
14928
14929 *list_size=4;
14930 return NULL;
14931 }
14932
14933 12 static ListData path_dlg_list(dirlist, &font);
14934
14935 static const char *wipestr[] = {"None", "Circle", "Oval", "Triangle", "SMAS", "Fade Black"};
14936 // enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
14937 const char *wipelist(int32_t index, int32_t *list_size)
14938 {
14939 if(index>=0)
14940 {
14941 if(index>5)
14942 index=5;
14943
14944 return wipestr[index];
14945 }
14946
14947 *list_size=6;
14948 return NULL;
14949 }
14950
14951 12 static ListData wipe_effect_dlg_list(wipelist, &font);
14952
14953 static DIALOG path_dlg[] =
14954 {
14955 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
14956 12 { jwin_win_proc, 80, 57, 161, 182, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Maze Path", NULL, NULL },
14957 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
14958 12 { jwin_text_proc, 94, 106, 192, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "1st", NULL, NULL },
14959 12 { jwin_text_proc, 94, 124, 192, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "2nd", NULL, NULL },
14960 12 { jwin_text_proc, 94, 142, 192, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "3rd", NULL, NULL },
14961 12 { jwin_text_proc, 94, 160, 192, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "4th", NULL, NULL },
14962 12 { jwin_text_proc, 94, 178, 192, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Exit", NULL, NULL },
14963 12 { jwin_text_proc, 94, 196, 192, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Wipe effect", NULL, NULL },
14964 12 { jwin_droplist_proc, 140, 102, 80+1, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &path_dlg_list, NULL, NULL },
14965 12 { jwin_droplist_proc, 140, 120, 80+1, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &path_dlg_list, NULL, NULL },
14966 12 { jwin_droplist_proc, 140, 138, 80+1, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &path_dlg_list, NULL, NULL },
14967 12 { jwin_droplist_proc, 140, 156, 80+1, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &path_dlg_list, NULL, NULL },
14968 12 { jwin_droplist_proc, 140, 174, 80+1, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &path_dlg_list, NULL, NULL },
14969 12 { jwin_droplist_proc, 140, 192, 80+1, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &wipe_effect_dlg_list, NULL, NULL },
14970 12 { jwin_button_proc, 90, 212, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
14971 12 { jwin_button_proc, 170, 212, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
14972 12 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onHelp, NULL, NULL },
14973 12 { jwin_text_proc, 87, 82, 192, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "A Lost Woods-style maze screen", NULL, NULL },
14974 12 { jwin_text_proc, 87, 92, 192, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "with a normal and secret exit.", NULL, NULL },
14975 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
14976 };
14977
14978 int32_t onPath()
14979 {
14980 restore_mouse();
14981 path_dlg[0].dp2=get_zc_font(font_lfont);
14982
14983 for(int32_t i=0; i<4; i++)
14984 path_dlg[i+8].d1 = Map.CurrScr()->path[i];
14985
14986 path_dlg[12].d1 = Map.CurrScr()->exitdir;
14987 path_dlg[13].d1 = Map.CurrScr()->maze_transition_wipe;
14988
14989 large_dialog(path_dlg);
14990
14991 int32_t ret;
14992
14993 do
14994 {
14995 ret=do_zqdialog(path_dlg,8);
14996
14997 if(ret==14)
14998 {
14999 for(int32_t i=0; i<4; i++)
15000 {
15001 if(path_dlg[i+8].d1 == path_dlg[12].d1)
15002 {
15003 if(jwin_alert("Exit Problem","One of the path's directions is","also the normal Exit direction! Continue?",NULL,"Yes","No",'y','n',get_zc_font(font_lfont))==2)
15004 ret = -1;
15005
15006 break;
15007 }
15008 }
15009 }
15010 }
15011 while(ret == -1);
15012
15013 if(ret==14)
15014 {
15015 mark_save_dirty();
15016
15017 for(int32_t i=0; i<4; i++)
15018 Map.CurrScr()->path[i] = path_dlg[i+8].d1;
15019
15020 Map.CurrScr()->exitdir = path_dlg[12].d1;
15021 Map.CurrScr()->maze_transition_wipe = path_dlg[13].d1;
15022
15023 if(!(Map.CurrScr()->flags&fMAZE))
15024 if(jwin_alert("Screen Flag","Turn on the 'Use Maze Path' Screen Flag?","(Go to 'Screen Data' to turn it off.)",NULL,"Yes","No",'y','n',get_zc_font(font_lfont))==1)
15025 Map.CurrScr()->flags |= fMAZE;
15026 }
15027
15028 refresh(rMAP+rMENU);
15029 return D_O_K;
15030 }
15031
15032
15033
15034 static DIALOG editinfo_dlg[] =
15035 {
15036 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
15037 12 { jwin_win_proc, 0, 10, 208, 204, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
15038 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
15039 12 { jwin_text_proc, 24, 60, 48, 8, vc(7), vc(1), 0, 0, 0, 0, (void *) "1st", NULL, NULL },
15040 12 { jwin_text_proc, 24, 106, 48, 8, vc(7), vc(1), 0, 0, 0, 0, (void *) "2nd", NULL, NULL },
15041 12 { jwin_text_proc, 24, 152, 48, 8, vc(7), vc(1), 0, 0, 0, 0, (void *) "3rd", NULL, NULL },
15042 12 { jwin_text_proc, 56, 60, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Price:", NULL, NULL },
15043 12 { jwin_text_proc, 56, 106, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Price:", NULL, NULL },
15044 12 { jwin_text_proc, 56, 152, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Price:", NULL, NULL },
15045 // 8
15046 12 { jwin_edit_proc, 86, 56, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
15047 12 { d_ndroplist_proc, 56, 74, 137, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
15048 12 { jwin_edit_proc, 86, 102, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
15049 12 { d_ndroplist_proc, 56, 120, 137, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
15050 12 { jwin_edit_proc, 86, 148, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
15051 12 { d_ndroplist_proc, 56, 166, 137, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
15052 12 { jwin_text_proc, 24, 42, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Name:", NULL, NULL },
15053 12 { jwin_edit_proc, 56, 38, 137, 16, vc(12), vc(1), 0, 0, 31, 0, NULL, NULL, NULL },
15054 // 16
15055 12 { jwin_button_proc, 34, 188, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
15056 12 { jwin_button_proc, 114, 188, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
15057 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
15058 };
15059
15060 void EditInfoType(int32_t index)
15061 {
15062 char ps1[6],ps2[6],ps3[6];
15063 char infoname[33];
15064 char caption[40];
15065
15066 int32_t str1, str2, str3;
15067
15068 sprintf(caption,"Info Data %d",index);
15069 editinfo_dlg[0].dp = caption;
15070 editinfo_dlg[0].dp2 = get_zc_font(font_lfont);
15071
15072 sprintf(ps1,"%d",QMisc.info[index].price[0]);
15073 sprintf(ps2,"%d",QMisc.info[index].price[1]);
15074 sprintf(ps3,"%d",QMisc.info[index].price[2]);
15075 strncpy(infoname,QMisc.info[index].name,32);
15076 infoname[32] = 0;
15077 editinfo_dlg[8].dp = ps1;
15078 editinfo_dlg[10].dp = ps2;
15079 editinfo_dlg[12].dp = ps3;
15080 editinfo_dlg[15].dp = infoname;
15081 str1 = QMisc.info[index].str[0];
15082 str2 = QMisc.info[index].str[1];
15083 str3 = QMisc.info[index].str[2];
15084 editinfo_dlg[9].d1 = MsgStrings[str1].listpos;
15085 editinfo_dlg[11].d1 = MsgStrings[str2].listpos;
15086 editinfo_dlg[13].d1 = MsgStrings[str3].listpos;
15087 ListData msgs_list(msgslist2, &a4fonts[font_lfont_l]);
15088 editinfo_dlg[9].dp =
15089 editinfo_dlg[11].dp =
15090 editinfo_dlg[13].dp = (void *) &msgs_list;
15091
15092 large_dialog(editinfo_dlg);
15093
15094 int32_t ret = do_zqdialog(editinfo_dlg,-1);
15095
15096 if(ret==16)
15097 {
15098 mark_save_dirty();
15099 QMisc.info[index].price[0] = vbound(atoi(ps1), 0, 65535);
15100 QMisc.info[index].price[1] = vbound(atoi(ps2), 0, 65535);
15101 QMisc.info[index].price[2] = vbound(atoi(ps3), 0, 65535);
15102 strncpy(QMisc.info[index].name,infoname,32);
15103 str1 = editinfo_dlg[9].d1;
15104 str2 = editinfo_dlg[11].d1;
15105 str3 = editinfo_dlg[13].d1;
15106 QMisc.info[index].str[0] = msg_at_pos(str1);
15107 QMisc.info[index].str[1] = msg_at_pos(str2);
15108 QMisc.info[index].str[2] = msg_at_pos(str3);
15109
15110 //move 0s to the end
15111 word swaptmp;
15112
15113 if(QMisc.info[index].str[0] == 0)
15114 {
15115 //possibly permute the infos
15116 if(QMisc.info[index].str[1] != 0)
15117 {
15118 //swap
15119 swaptmp = QMisc.info[index].str[0];
15120 QMisc.info[index].str[0] = QMisc.info[index].str[1];
15121 QMisc.info[index].str[1] = swaptmp;
15122 swaptmp = QMisc.info[index].price[0];
15123 QMisc.info[index].price[0] = QMisc.info[index].price[1];
15124 QMisc.info[index].price[1] = swaptmp;
15125 }
15126 else if(QMisc.info[index].str[2] != 0)
15127 {
15128 //move info 0 to 1, 1 to 2, and 2 to 0
15129 swaptmp = QMisc.info[index].str[0];
15130 QMisc.info[index].str[0] = QMisc.info[index].str[2];
15131 QMisc.info[index].str[2] = QMisc.info[index].str[1];
15132 QMisc.info[index].str[1] = swaptmp;
15133 swaptmp = QMisc.info[index].price[0];
15134 QMisc.info[index].price[0] = QMisc.info[index].price[2];
15135 QMisc.info[index].price[2] = QMisc.info[index].price[1];
15136 QMisc.info[index].price[1] = swaptmp;
15137 }
15138 }
15139
15140 if(QMisc.info[index].str[1] == 0 && QMisc.info[index].str[2] != 0)
15141 //swap
15142 {
15143 swaptmp = QMisc.info[index].str[1];
15144 QMisc.info[index].str[1] = QMisc.info[index].str[2];
15145 QMisc.info[index].str[2] = swaptmp;
15146 swaptmp = QMisc.info[index].price[1];
15147 QMisc.info[index].price[1] = QMisc.info[index].price[2];
15148 QMisc.info[index].price[2] = swaptmp;
15149 }
15150 }
15151 }
15152
15153 int32_t onInfoTypes()
15154 {
15155 info_list_size = 256;
15156
15157 int32_t index = select_data("Info Types",0,infolist,"Edit","Done",get_zc_font(font_lfont));
15158
15159 while(index!=-1)
15160 {
15161 EditInfoType(index);
15162
15163 index = select_data("Info Types",index,infolist,"Edit","Done",get_zc_font(font_lfont));
15164 }
15165
15166 return D_O_K;
15167 }
15168
15169
15170
15171 //This dialogie is self-contained, and does not use dialogue control numbers in a separate array to generate its fields.
15172 static DIALOG editshop_dlg[] =
15173 {
15174 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
15175 12 { jwin_win_proc, 0, 10, 221, 204, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
15176 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
15177 12 { jwin_text_proc, 24, 60, 48, 8, vc(7), vc(1), 0, 0, 0, 0, (void *) "1st", NULL, NULL },
15178 12 { jwin_text_proc, 24, 106, 48, 8, vc(7), vc(1), 0, 0, 0, 0, (void *) "2nd", NULL, NULL },
15179 12 { jwin_text_proc, 24, 152, 48, 8, vc(7), vc(1), 0, 0, 0, 0, (void *) "3rd", NULL, NULL },
15180 12 { jwin_text_proc, 56, 60, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Price:", NULL, NULL },
15181 12 { jwin_text_proc, 56, 106, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Price:", NULL, NULL },
15182 12 { jwin_text_proc, 56, 152, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Price:", NULL, NULL },
15183 // 8
15184 12 { jwin_edit_proc, 86, 56, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
15185 12 { d_nidroplist_proc, 56, 74, 137, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
15186 12 { jwin_edit_proc, 86, 102, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
15187 12 { d_nidroplist_proc, 56, 120, 137, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
15188 12 { jwin_edit_proc, 86, 148, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
15189 12 { d_nidroplist_proc, 56, 166, 137, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
15190 12 { jwin_text_proc, 24, 42, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Name:", NULL, NULL },
15191 12 { jwin_edit_proc, 56, 38, 137, 16, vc(12), vc(1), 0, 0, 31, 0, NULL, NULL, NULL },
15192
15193 // 16
15194 12 { jwin_button_proc, 40, 188, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
15195 12 { jwin_button_proc, 121, 188, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
15196 //18
15197 12 { jwin_text_proc, 130, 60, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Info:", NULL, NULL },
15198 12 { jwin_text_proc, 130, 106, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Info:", NULL, NULL },
15199 12 { jwin_text_proc, 130, 152, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Info:", NULL, NULL },
15200 // 21
15201 12 { jwin_edit_proc, 155, 56, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
15202 12 { jwin_edit_proc, 155, 102, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
15203 12 { jwin_edit_proc, 155, 148, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
15204
15205 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
15206 };
15207
15208 void EditShopType(int32_t index)
15209 {
15210
15211 build_bii_list(true);
15212 char ps1[6],ps2[6],ps3[6];
15213 char info1[6],info2[6],info3[6];
15214 char shopname[32];
15215 char caption[40];
15216
15217 sprintf(caption,"Shop Data %d",index);
15218 editshop_dlg[0].dp = caption;
15219 editshop_dlg[0].dp2=get_zc_font(font_lfont);
15220
15221 sprintf(ps1,"%d",QMisc.shop[index].price[0]);
15222 sprintf(ps2,"%d",QMisc.shop[index].price[1]);
15223 sprintf(ps3,"%d",QMisc.shop[index].price[2]);
15224
15225 sprintf(info1,"%d",QMisc.shop[index].str[0]);
15226 sprintf(info2,"%d",QMisc.shop[index].str[1]);
15227 sprintf(info3,"%d",QMisc.shop[index].str[2]);
15228
15229 sprintf(shopname,"%s",QMisc.shop[index].name);
15230 editshop_dlg[8].dp = ps1;
15231 editshop_dlg[10].dp = ps2;
15232 editshop_dlg[12].dp = ps3;
15233 editshop_dlg[15].dp = shopname;
15234
15235 editshop_dlg[21].dp = info1;
15236 editshop_dlg[22].dp = info2;
15237 editshop_dlg[23].dp = info3;
15238
15239 ListData item_list(itemlist_num, &a4fonts[font_lfont_l]);
15240
15241 editshop_dlg[9].dp = (void *) &item_list;
15242 editshop_dlg[11].dp = (void *) &item_list;
15243 editshop_dlg[13].dp = (void *) &item_list;
15244
15245 for(int32_t i=0; i<3; ++i)
15246 {
15247 if(QMisc.shop[index].hasitem[i])
15248 {
15249 for(int32_t j=0; j<bii_cnt; j++)
15250 {
15251 if(bii[j].i == QMisc.shop[index].item[i])
15252 {
15253 editshop_dlg[9+(i<<1)].d1 = j;
15254 }
15255 }
15256 }
15257 else
15258 {
15259 editshop_dlg[9+(i<<1)].d1 = -2;
15260 }
15261 }
15262
15263 large_dialog(editshop_dlg);
15264
15265 int32_t ret = do_zqdialog(editshop_dlg,-1);
15266
15267 if(ret==16)
15268 {
15269 mark_save_dirty();
15270 QMisc.shop[index].price[0] = vbound(atoi(ps1), 0, 65535);
15271 QMisc.shop[index].price[1] = vbound(atoi(ps2), 0, 65535);
15272 QMisc.shop[index].price[2] = vbound(atoi(ps3), 0, 65535);
15273
15274 QMisc.shop[index].str[0] = vbound(atoi(info1), 0, 65535);
15275 QMisc.shop[index].str[1] = vbound(atoi(info2), 0, 65535);
15276 QMisc.shop[index].str[2] = vbound(atoi(info3), 0, 65535);
15277
15278 snprintf(QMisc.shop[index].name, 32, "%s",shopname);
15279
15280 for(int32_t i=0; i<3; ++i)
15281 {
15282 if(bii[editshop_dlg[9+(i<<1)].d1].i == -2)
15283 {
15284 QMisc.shop[index].hasitem[i] = 0;
15285 QMisc.shop[index].item[i] = 0;
15286 QMisc.shop[index].price[i] = 0;
15287 }
15288 else
15289 {
15290 QMisc.shop[index].hasitem[i] = 1;
15291 QMisc.shop[index].item[i] = bii[editshop_dlg[9+(i<<1)].d1].i;
15292 }
15293 }
15294
15295 //filter all the 0 items to the end (yeah, bubble sort; sue me)
15296 word swaptmp;
15297
15298 for(int32_t j=0; j<3-1; j++)
15299 {
15300 for(int32_t k=0; k<2-j; k++)
15301 {
15302 if(QMisc.shop[index].hasitem[k]==0)
15303 {
15304 swaptmp = QMisc.shop[index].item[k];
15305 QMisc.shop[index].item[k] = QMisc.shop[index].item[k+1];
15306 QMisc.shop[index].item[k+1] = swaptmp;
15307 swaptmp = QMisc.shop[index].price[k];
15308 QMisc.shop[index].price[k] = QMisc.shop[index].price[k+1];
15309 QMisc.shop[index].price[k+1] = swaptmp;
15310 swaptmp = QMisc.shop[index].hasitem[k];
15311 QMisc.shop[index].hasitem[k] = QMisc.shop[index].item[k+1];
15312 QMisc.shop[index].hasitem[k+1] = swaptmp;
15313 }
15314 }
15315 }
15316 }
15317 }
15318
15319 int32_t onShopTypes()
15320 {
15321 shop_list_size = 256;
15322
15323 int32_t index = select_data("Shop Types",0,shoplist,"Edit","Done",get_zc_font(font_lfont));
15324
15325 while(index!=-1)
15326 {
15327 EditShopType(index);
15328 index = select_data("Shop Types",index,shoplist,"Edit","Done",get_zc_font(font_lfont));
15329 }
15330
15331 return D_O_K;
15332 }
15333
15334 void call_bottle_dlg(int32_t index);
15335 int32_t onBottleTypes()
15336 {
15337 bottle_list_size = 64;
15338 int32_t index = 0;
15339
15340 while(index > -1)
15341 {
15342 index = select_data("Bottle Types", index, bottlelist, "Edit", "Done", get_zc_font(font_lfont));
15343 if(index > -1)
15344 call_bottle_dlg(index);
15345 }
15346
15347 return D_O_K;
15348 }
15349
15350 void call_bottleshop_dlg(int32_t index);
15351 int32_t onBottleShopTypes()
15352 {
15353 bottleshop_list_size = 256;
15354 int32_t index = 0;
15355
15356 while(index > -1)
15357 {
15358 index = select_data("Bottle Shop Types", index, bottleshoplist, "Edit", "Done", get_zc_font(font_lfont));
15359 if(index > -1)
15360 call_bottleshop_dlg(index);
15361 }
15362
15363 return D_O_K;
15364 }
15365
15366 int32_t onSaveMenus()
15367 {
15368 SaveMenuListerDialog().show();
15369 return D_O_K;
15370 }
15371
15372
15373 static char item_drop_set_str_buf[70];
15374 int32_t item_drop_set_list_size=MAXITEMDROPSETS;
15375
15376 const char *itemdropsetlist(int32_t index, int32_t *list_size)
15377 {
15378 if(index>=0)
15379 {
15380 bound(index,0,item_drop_set_list_size-1);
15381 sprintf(item_drop_set_str_buf,"%3d: %s",index,item_drop_sets[index].name);
15382 return item_drop_set_str_buf;
15383 }
15384
15385 *list_size=item_drop_set_list_size;
15386 return NULL;
15387 }
15388
15389 int32_t d_itemdropedit_proc(int32_t msg,DIALOG *d,int32_t c);
15390
15391 static int32_t edititemdropset_1_list[] =
15392 {
15393 // dialog control number
15394 10, 11, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,24,25,26,27,28, -1
15395 };
15396
15397 static int32_t edititemdropset_2_list[] =
15398 {
15399 // dialog control number
15400 12, 13, 29, 30, 31, 32, 33,34,35,36,37,38,39,40,41,42,43, -1
15401 };
15402
15403 static TABPANEL edititemdropset_tabs[] =
15404 {
15405 // (text)
15406 { (char *)" Page 1 ", D_SELECTED, edititemdropset_1_list, 0, NULL },
15407 { (char *)" Page 2 ", 0, edititemdropset_2_list, 0, NULL },
15408 { NULL, 0, NULL, 0, NULL }
15409 };
15410
15411 static DIALOG edititemdropset_dlg[] =
15412 {
15413 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
15414 12 { jwin_win_proc, 0, 0, 320, 240, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
15415 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
15416
15417 // 2
15418 12 { jwin_button_proc, 89, 213, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
15419 12 { jwin_button_proc, 169, 213, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
15420
15421 // 4
15422 12 { jwin_text_proc, 9, 29, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Name:", NULL, NULL },
15423 12 { jwin_edit_proc, 39, 25, 275, 16, vc(12), vc(1), 0, 0, 32, 0, NULL, NULL, NULL },
15424 12 { jwin_text_proc, 9, 47, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Nothing Chance:", NULL, NULL },
15425 12 { d_itemdropedit_proc, 84, 43, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
15426
15427 12 { jwin_tab_proc, 4, 65, 312, 143, vc(0), vc(15), 0, 0, 0, 0, (void *) edititemdropset_tabs, NULL, (void *)edititemdropset_dlg },
15428 12 { jwin_text_proc, 114, 43+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
15429 // 10
15430 12 { jwin_text_proc, 10, 87, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Chance:", NULL, NULL },
15431 12 { jwin_text_proc, 56, 87, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Item:", NULL, NULL },
15432 12 { jwin_text_proc, 10, 87, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Chance:", NULL, NULL },
15433 12 { jwin_text_proc, 56, 87, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Item:", NULL, NULL },
15434
15435 // 14
15436 12 { d_itemdropedit_proc, 9, 96, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
15437 12 { d_idroplist_proc, 55, 96, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
15438 12 { jwin_text_proc, 37, 96+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
15439 12 { d_itemdropedit_proc, 9, 118, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
15440 12 { d_idroplist_proc, 55, 118, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
15441 12 { jwin_text_proc, 37, 118+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
15442 12 { d_itemdropedit_proc, 9, 140, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
15443 12 { d_idroplist_proc, 55, 140, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
15444 12 { jwin_text_proc, 37, 140+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
15445 12 { d_itemdropedit_proc, 9, 162, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
15446 12 { d_idroplist_proc, 55, 162, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
15447 12 { jwin_text_proc, 37, 162+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
15448 12 { d_itemdropedit_proc, 9, 184, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
15449 12 { d_idroplist_proc, 55, 184, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
15450 12 { jwin_text_proc, 37, 184+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
15451 // 29
15452 12 { d_itemdropedit_proc, 9, 96, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
15453 12 { d_idroplist_proc, 55, 96, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
15454 12 { jwin_text_proc, 37, 96+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
15455 12 { d_itemdropedit_proc, 9, 118, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
15456 12 { d_idroplist_proc, 55, 118, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
15457 12 { jwin_text_proc, 37, 118+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
15458 12 { d_itemdropedit_proc, 9, 140, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
15459 12 { d_idroplist_proc, 55, 140, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
15460 12 { jwin_text_proc, 37, 140+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
15461 12 { d_itemdropedit_proc, 9, 162, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
15462 12 { d_idroplist_proc, 55, 162, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
15463 12 { jwin_text_proc, 37, 162+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
15464 12 { d_itemdropedit_proc, 9, 184, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
15465 12 { d_idroplist_proc, 55, 184, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
15466 12 { jwin_text_proc, 39, 184+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
15467 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
15468 };
15469
15470 int32_t d_itemdropedit_proc(int32_t msg,DIALOG *d,int32_t c)
15471 {
15472 int32_t ret = jwin_edit_proc(msg,d,c);
15473
15474 if(msg==MSG_DRAW)
15475 {
15476 int32_t t = atoi((char*)edititemdropset_dlg[7].dp);
15477
15478 for(int32_t i=0; i<10; ++i)
15479 {
15480 t += atoi((char*)edititemdropset_dlg[14+(i*3)].dp);
15481 }
15482
15483 {
15484 int32_t t2 = (int32_t)(100*atoi((char*)edititemdropset_dlg[7].dp) / zc_max(t,1));
15485 sprintf((char*)edititemdropset_dlg[9].dp,"%d%%%s",t2, t2 <= 11 ? " ":"");
15486 object_message(&edititemdropset_dlg[9],MSG_DRAW,c);
15487 }
15488
15489 for(int32_t i=0; i<10; ++i)
15490 {
15491 int32_t t2 = (int32_t)(100*atoi((char*)edititemdropset_dlg[14+(i*3)].dp) / zc_max(t,1));
15492 sprintf((char*)edititemdropset_dlg[16+(i*3)].dp,"%d%%%s",t2, t2 <= 11 ? " ":"");
15493 object_message(&edititemdropset_dlg[16+(i*3)],MSG_DRAW,c);
15494 }
15495
15496 }
15497
15498 return ret;
15499 }
15500
15501 void EditItemDropSet(int32_t index)
15502 {
15503 build_bii_list(true);
15504 char chance[11][10];
15505 char itemdropsetname[64];
15506 char caption[40];
15507 char percent_str[11][5];
15508
15509 sprintf(caption,"Item Drop Set Data %d",index);
15510 edititemdropset_dlg[0].dp = caption;
15511 edititemdropset_dlg[0].dp2=get_zc_font(font_lfont);
15512
15513 sprintf(itemdropsetname,"%s",item_drop_sets[index].name);
15514 edititemdropset_dlg[5].dp = itemdropsetname;
15515
15516 sprintf(chance[0],"%d",item_drop_sets[index].chance[0]);
15517 edititemdropset_dlg[7].dp = chance[0];
15518
15519 ListData item_list(itemlist_num, &a4fonts[font_lfont_l]);
15520 sprintf(percent_str[0]," ");
15521 edititemdropset_dlg[9].dp = percent_str[0];
15522
15523 for(int32_t i=0; i<10; ++i)
15524 {
15525 sprintf(chance[i+1],"%d",item_drop_sets[index].chance[i+1]);
15526 edititemdropset_dlg[14+(i*3)].dp = chance[i+1];
15527 edititemdropset_dlg[15+(i*3)].dp = (void *) &item_list;
15528 sprintf(percent_str[i+1]," ");
15529 edititemdropset_dlg[16+(i*3)].dp = percent_str[i+1];
15530
15531 if(item_drop_sets[index].chance[i+1]==0)
15532 {
15533 edititemdropset_dlg[15+(i*3)].d1 = -2;
15534 }
15535 else
15536 {
15537 for(int32_t j=0; j<bii_cnt; j++)
15538 {
15539 if(bii[j].i == item_drop_sets[index].item[i])
15540 {
15541 edititemdropset_dlg[15+(i*3)].d1 = j;
15542 }
15543 }
15544 }
15545 }
15546
15547 large_dialog(edititemdropset_dlg);
15548
15549 int32_t ret = do_zqdialog(edititemdropset_dlg,-1);
15550
15551 if(ret==2)
15552 {
15553 mark_save_dirty();
15554
15555 sprintf(item_drop_sets[index].name,"%s",itemdropsetname);
15556
15557 item_drop_sets[index].chance[0]=atoi(chance[0]);
15558
15559 for(int32_t i=0; i<10; ++i)
15560 {
15561 item_drop_sets[index].chance[i+1]=atoi(chance[i+1]);
15562
15563 if(bii[edititemdropset_dlg[15+(i*3)].d1].i == -2)
15564 {
15565 item_drop_sets[index].chance[i+1]=0;
15566 }
15567 else
15568 {
15569 item_drop_sets[index].item[i] = bii[edititemdropset_dlg[15+(i*3)].d1].i;
15570 }
15571
15572 if(item_drop_sets[index].chance[i+1]==0)
15573 {
15574 item_drop_sets[index].item[i] = 0;
15575 }
15576 }
15577 }
15578 }
15579
15580 9 int32_t count_item_drop_sets()
15581 {
15582 9 int32_t count=0;
15583 9 bool found=false;
15584
15585
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2195 times.
2195 for(count=255; (count>0); --count)
15586 {
15587
2/2
✓ Branch 0 taken 2186 times.
✓ Branch 1 taken 24056 times.
26242 for(int32_t i=0; (i<11); ++i)
15588 {
15589
2/2
✓ Branch 0 taken 24047 times.
✓ Branch 1 taken 9 times.
24056 if(item_drop_sets[count].chance[i]!=0)
15590 {
15591 9 found=true;
15592 9 break;
15593 }
15594 24047 }
15595
15596
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2186 times.
2195 if(found)
15597 {
15598 9 break;
15599 }
15600 2186 }
15601
15602 9 return count+1;
15603 }
15604
15605 int32_t onItemDropSets()
15606 {
15607 item_drop_set_list_size = MAXITEMDROPSETS;
15608
15609 int32_t index = select_data("Item Drop Sets",0,itemdropsetlist,"Edit","Done",get_zc_font(font_lfont));
15610
15611 while(index!=-1)
15612 {
15613 EditItemDropSet(index);
15614 index = select_data("Item Drop Sets",index,itemdropsetlist,"Edit","Done",get_zc_font(font_lfont));
15615 }
15616
15617 return D_O_K;
15618 }
15619
15620 int32_t curr_ring = 0;
15621
15622 void EditWarpRingScr(int32_t ring,int32_t index)
15623 {
15624 char caption[40],buf[10];
15625 restore_mouse();
15626
15627 sprintf(caption,"Ring %d Warp %d",ring,index+1);
15628 warpring_warp_dlg[0].dp = (void *)caption;
15629 warpring_warp_dlg[0].dp2=get_zc_font(font_lfont);
15630
15631 sprintf(buf,"%02X",QMisc.warp[ring].scr[index]);
15632 warpring_warp_dlg[3].d1 = QMisc.warp[ring].dmap[index];
15633 warpring_warp_dlg[4].dp = buf;
15634 warpring_warp_dlg[8].dp = buf;
15635 warpring_warp_dlg[8].dp3 = &warpring_warp_dlg[3].d1;
15636
15637 vector<DIALOG*> dlgs;
15638 dlgs.push_back(&warpring_warp_dlg[3]);
15639 dlgs.push_back(&warpring_warp_dlg[4]);
15640 warpring_warp_dlg[8].dp2 = &dlgs;
15641
15642 dmap_list_size=MAXDMAPS;
15643 dmap_list_zero=true;
15644
15645 large_dialog(warpring_warp_dlg);
15646
15647 int32_t ret=do_zqdialog(warpring_warp_dlg,-1);
15648
15649 if(ret==5 || ret==6)
15650 {
15651 mark_save_dirty();
15652 QMisc.warp[ring].dmap[index] = warpring_warp_dlg[3].d1;
15653 QMisc.warp[ring].scr[index] = zc_xtoi(buf);
15654 }
15655
15656 if(ret==6)
15657 {
15658 Map.dowarp2(ring,index);
15659 refresh(rALL);
15660 }
15661 }
15662
15663 int32_t d_warplist_proc(int32_t msg,DIALOG *d,int32_t c)
15664 {
15665 if(msg==MSG_DRAW)
15666 {
15667 int32_t *xy = (int32_t*)(d->dp3);
15668 int32_t ring = curr_ring;
15669 int32_t dmap = QMisc.warp[ring].dmap[d->d1];
15670 float temp_scale = 1.5;
15671
15672 drawdmap(dmap);
15673
15674 if(xy[0]||xy[1])
15675 {
15676 int32_t x = d->x+int32_t((xy[0]-2)*temp_scale);
15677 int32_t y = d->y+int32_t((xy[1]-2)*temp_scale);
15678 int32_t w = 84;
15679 int32_t h = 52;
15680 jwin_draw_frame(screen,x,y,w,h,FR_DEEP);
15681 drawdmap_screen(x+2,y+2,w-4,h-4,dmap);
15682 }
15683
15684 if(xy[2]||xy[3])
15685 {
15686 textprintf_ex(screen,font,d->x+int32_t(xy[2]*temp_scale),d->y+int32_t(xy[3]*temp_scale),jwin_pal[jcBOXFG],jwin_pal[jcBOX],"Map: %d ",DMaps[dmap].map+1);
15687 }
15688
15689 if(xy[4]||xy[5])
15690 {
15691 textprintf_ex(screen,font,d->x+int32_t(xy[4]*temp_scale),d->y+int32_t(xy[5]*temp_scale),jwin_pal[jcBOXFG],jwin_pal[jcBOX],"Level:%2d ",DMaps[dmap].level);
15692 }
15693
15694 if(xy[6]||xy[7])
15695 {
15696 textprintf_ex(screen,font,d->x+int32_t(xy[6]*temp_scale),d->y+int32_t(xy[7]*temp_scale),jwin_pal[jcBOXFG],jwin_pal[jcBOX],"Scr: 0x%02X ",QMisc.warp[ring].scr[d->d1]);
15697 }
15698 }
15699
15700 return jwin_list_proc(msg,d,c);
15701 }
15702
15703 int32_t d_wclist_proc(int32_t msg,DIALOG *d,int32_t c)
15704 {
15705 int32_t d1 = d->d1;
15706 int32_t ret = jwin_droplist_proc(msg,d,c);
15707 QMisc.warp[curr_ring].size=d->d1+3;
15708
15709 if(d->d1 != d1)
15710 return D_CLOSE;
15711
15712 return ret;
15713 }
15714
15715 const char *wclist(int32_t index, int32_t *list_size)
15716 {
15717 static char buf[2];
15718
15719 if(index>=0)
15720 {
15721 if(index>6)
15722 index=6;
15723
15724 sprintf(buf,"%d",index+3);
15725 return buf;
15726 }
15727
15728 *list_size=7;
15729 return NULL;
15730 }
15731
15732 //int32_t warpringdmapxy[8] = {160,116,160,90,160,102,160,154};
15733 int32_t warpringdmapxy[8] = {80,26,80,0,80,12,80,78};
15734
15735 12 static ListData number_list(numberlist, &font);
15736 12 static ListData wc_list(wclist, &font);
15737
15738 static DIALOG warpring_dlg[] =
15739 {
15740 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
15741 12 { jwin_win_proc, 0, 0, 193, 166, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
15742 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
15743 12 { jwin_text_proc, 16, 33, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Count:", NULL, NULL },
15744 12 { d_wclist_proc, 72, 29, 48, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 1, 0, (void *) &wc_list, NULL, NULL },
15745 // 4
15746 12 { d_warplist_proc, 16, 50, 65, 71, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, (void *) &number_list, NULL, warpringdmapxy },
15747 12 { jwin_button_proc, 26, 140, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Edit", NULL, NULL },
15748 12 { jwin_button_proc, 106, 140, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Done", NULL, NULL },
15749 12 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onHelp, NULL, NULL },
15750 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
15751 };
15752
15753 int32_t select_warp()
15754 {
15755 QMisc.warp[curr_ring].size = vbound(QMisc.warp[curr_ring].size,3,9);
15756 number_list_zero = false;
15757
15758 int32_t ret=4;
15759
15760 large_dialog(warpring_dlg);
15761
15762 do
15763 {
15764 number_list_size = QMisc.warp[curr_ring].size;
15765 warpring_dlg[3].d1 = QMisc.warp[curr_ring].size-3;
15766 ret = do_zqdialog(warpring_dlg,ret);
15767 }
15768 while(ret==3);
15769
15770 if(ret==6 || ret==0)
15771 {
15772 return -1;
15773 }
15774
15775 return warpring_dlg[4].d1;
15776 }
15777
15778 void EditWarpRing(int32_t ring)
15779 {
15780 char buf[40];
15781 sprintf(buf,"Ring %d Warps",ring);
15782 warpring_dlg[0].dp = buf;
15783 warpring_dlg[0].dp2 = get_zc_font(font_lfont);
15784 curr_ring = ring;
15785
15786 int32_t index = select_warp();
15787
15788 while(index!=-1)
15789 {
15790 EditWarpRingScr(ring,index);
15791 index = select_warp();
15792 }
15793 }
15794
15795 int32_t onWarpRings()
15796 {
15797 number_list_size = 9;
15798 number_list_zero = true;
15799
15800 int32_t index = select_data("Warp Rings",0,numberlist,"Edit","Done",get_zc_font(font_lfont));
15801
15802 while(index!=-1)
15803 {
15804 EditWarpRing(index);
15805 number_list_size = 9;
15806 number_list_zero = true;
15807 index = select_data("Warp Rings",index,numberlist,"Edit","Done",get_zc_font(font_lfont));
15808 }
15809
15810 return D_O_K;
15811 }
15812
15813 enemy_struct bie[eMAXGUYS];
15814 enemy_struct ce[100];
15815 int32_t enemy_type=0,bie_cnt=-1,ce_cnt;
15816
15817 //Uses old_max_guys[] in zq_misc.cpp to define what are visible if bool hide is set true. -Z
15818 void build_bie_list(bool hide)
15819 {
15820 bie[0].s = (char *)"(None)";
15821 bie[0].i = 0;
15822 bie_cnt=1;
15823
15824 for(int32_t i=1; i<eMAXGUYS; i++)
15825 {
15826 if (i < eSTART) continue; // ignore guys - enemies only!
15827
15828 if(i >= OLDMAXGUYS || old_guy_string[i][strlen(old_guy_string[i])-1]!=' ' || !hide)
15829 {
15830 bie[bie_cnt].s = (char *)guy_string[i];
15831 bie[bie_cnt].i = i;
15832 ++bie_cnt;
15833 }
15834 }
15835
15836 for(int32_t i=1; i<bie_cnt-1; i++) //Start at 1 so '(None)' isn't alphabetized!
15837 {
15838 for(int32_t j=i+1; j<bie_cnt; j++)
15839 {
15840 if(strcmp(bie[i].s,bie[j].s)>0)
15841 {
15842 zc_swap(bie[i],bie[j]);
15843 }
15844 }
15845 }
15846 }
15847
15848 int32_t efrontfacingtile(int32_t id)
15849 {
15850 int32_t anim = get_qr(qr_NEWENEMYTILES)?guysbuf[id].e_anim:guysbuf[id].anim;
15851 int32_t usetile = 0;
15852
15853 switch(anim)
15854 {
15855
15856 case aNONE: break;
15857 case aAQUA:
15858 if(!(get_qr(qr_NEWENEMYTILES) && guysbuf[id].attributes[0]))
15859 break;
15860
15861 case aWALLM:
15862 case aGHOMA:
15863 usetile=1;
15864 break;
15865
15866 //Fallthrough
15867 case a2FRM4DIR:
15868 case aWALK:
15869 usetile=2;
15870 break;
15871
15872 case aLEV:
15873 case a3FRM4DIR:
15874 usetile=3;
15875 break;
15876
15877 case aLANM:
15878 usetile = !(get_qr(qr_NEWENEMYTILES))?0:4;
15879 break;
15880
15881 case aNEWDONGO:
15882 case a4FRM8EYE:
15883 case aNEWWIZZ:
15884 case aARMOS4:
15885 case aNEWTEK:
15886 case aNEWWALLM:
15887 case a4FRM4DIRF:
15888 case a4FRM4DIR:
15889 case a4FRM8DIRF:
15890 case a4FRMPOS8DIR:
15891 case a4FRMPOS8DIRF:
15892 case a4FRMPOS4DIR:
15893 case a4FRMPOS4DIRF:
15894 usetile=4;
15895 break;
15896
15897 case aDONGO:
15898 usetile=6;
15899 break;
15900
15901 case aDONGOBS:
15902 usetile=24;
15903 break;
15904
15905 case aNEWLEV:
15906 usetile=40;
15907 break;
15908
15909 case aNEWZORA:
15910 if(guysbuf[id].type==eeZORA)
15911 usetile=44;
15912
15913 break;
15914
15915 case aGLEEOK:
15916 if(!get_qr(qr_NEWENEMYTILES))
15917 usetile = (guysbuf[id].s_tile - guysbuf[id].tile)+1;
15918 else
15919 usetile = (guysbuf[id].attributes[7]);
15920
15921 break;
15922 }
15923
15924 return zc_max(get_qr(qr_NEWENEMYTILES) ? -guysbuf[id].e_tile
15925 : -guysbuf[id].tile, usetile);
15926 }
15927
15928 int32_t onEnemies()
15929 {
15930 call_screenenemies_dialog();
15931 refresh(rALL);
15932 return D_O_K;
15933 }
15934
15935 int32_t onHeader()
15936 {
15937 call_header_dlg();
15938 return D_O_K;
15939 }
15940
15941 void call_cheats_dlg();
15942 int32_t onCheats()
15943 {
15944 call_cheats_dlg();
15945 return D_O_K;
15946 }
15947
15948 bool do_x_button(BITMAP *dest, int32_t x, int32_t y)
15949 {
15950 bool over=false;
15951
15952 while(gui_mouse_b())
15953 {
15954 custom_vsync();
15955
15956 if(isinRect(gui_mouse_x(),gui_mouse_y(),x,y,x+15,y+13))
15957 {
15958 if(!over)
15959 {
15960 draw_x_button(dest, x, y, D_SELECTED);
15961 over=true;
15962 }
15963 }
15964 else
15965 {
15966 if(over)
15967 {
15968 draw_x_button(dest, x, y, 0);
15969 over=false;
15970 }
15971 }
15972 }
15973
15974 return over;
15975 }
15976
15977 bool do_question_button(BITMAP *dest, int32_t x, int32_t y)
15978 {
15979 bool over=false;
15980
15981 while(gui_mouse_b())
15982 {
15983 custom_vsync();
15984
15985 if(isinRect(gui_mouse_x(),gui_mouse_y(),x,y,x+15,y+13))
15986 {
15987 if(!over)
15988 {
15989 draw_question_button(dest, x, y, D_SELECTED);
15990 over=true;
15991 }
15992 }
15993 else
15994 {
15995 if(over)
15996 {
15997 draw_question_button(dest, x, y, 0);
15998 over=false;
15999 }
16000 }
16001 }
16002
16003 return over;
16004 }
16005
16006
16007 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
16008 {
16009 return D_O_K;
16010 }
16011
16012 static int32_t last_combo=0;
16013 static int32_t last_cset=0;
16014
3/4
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98292 times.
✓ Branch 3 taken 12 times.
98304 static combo_alias temp_aliases[MAXCOMBOALIASES];
16015
16016 extern int32_t scheme[jcMAX];
16017
16018 int32_t d_comboa_proc(int32_t msg,DIALOG *d,int32_t c)
16019 {
16020 //these are here to bypass compiler warnings about unused arguments
16021 c=c;
16022
16023 combo_alias *combo;
16024 combo = &temp_aliases[comboa_cnt];
16025 int32_t position;
16026 int32_t cur_layer, temp_layer;
16027 int32_t lay_count=0;
16028 int32_t size = 2;
16029
16030 int32_t cx1=(gui_mouse_x()-d->x-(120-(combo->width*8)));
16031 int32_t cy1=(gui_mouse_y()-d->y-(80-(combo->height*8)));
16032 int32_t cx=cx1/(16*size);
16033 int32_t cy=cy1/(16*size);
16034
16035 int32_t co,cs;
16036
16037
16038 switch(msg)
16039 {
16040 case MSG_CLICK:
16041 if((cx>combo->width)||(cx1<0))
16042 return D_O_K;
16043
16044 if((cy>combo->height)||(cy1<0))
16045 return D_O_K;
16046
16047 for(int32_t j=0; j<layer_cnt; j++)
16048 {
16049 if(combo->layermask&(1<<j))
16050 lay_count++;
16051 }
16052
16053 position=(lay_count)*(combo->width+1)*(combo->height+1);
16054 position+=(cy*(combo->width+1))+cx;
16055
16056 if(key[KEY_LSHIFT]||key[KEY_RSHIFT])
16057 {
16058 combo->combos[position] = 0;
16059 combo->csets[position] = 0;
16060
16061 while(gui_mouse_b())
16062 {
16063 /* do nothing */
16064 rest(1);
16065 }
16066
16067 return D_REDRAW;
16068 }
16069
16070 co=combo->combos[position];
16071 cs=combo->csets[position];
16072
16073 if((co==0)||(key[KEY_ZC_LCONTROL]))
16074 {
16075 co=last_combo;
16076 cs=last_cset;
16077 }
16078
16079 if((select_combo_2(co,cs)))
16080 {
16081 last_combo = co;
16082 last_cset = cs;
16083
16084 combo->combos[position]=co;
16085 combo->csets[position]=cs;
16086 }
16087
16088 return D_REDRAW;
16089 break;
16090
16091 case MSG_DRAW:
16092 BITMAP *buf = create_bitmap_ex(8,d->w,d->h);
16093
16094 if(buf)
16095 {
16096 clear_bitmap(buf);
16097
16098 for(int32_t z=0; z<=comboa_lmasktotal(combo->layermask); z++)
16099 {
16100 int32_t k=0;
16101 cur_layer=0;
16102 temp_layer=combo->layermask;
16103
16104 while((temp_layer!=0)&&(k<z))
16105 {
16106 if(temp_layer&1)
16107 {
16108 k++;
16109 }
16110
16111 cur_layer++;
16112 temp_layer = temp_layer>>1;
16113 }
16114
16115 for(int32_t y=0; (y<d->h)&&((y/16)<=combo->height); y+=16)
16116 {
16117 for(int32_t x=0; (x<d->w)&&((x/16)<=combo->width); x+=16)
16118 {
16119 int32_t cpos = (z*(combo->width+1)*(combo->height+1))+(((y/16)*(combo->width+1))+(x/16));
16120
16121 if(combo->combos[cpos])
16122 {
16123 if(!((d-1)->flags&D_SELECTED)||(cur_layer==layer_cnt))
16124 {
16125 if(z==0)
16126 {
16127 puttile16(buf,combobuf[combo->combos[cpos]].tile,x,y,combo->csets[cpos],combobuf[combo->combos[cpos]].flip);
16128 }
16129 else
16130 {
16131 overtile16(buf,combobuf[combo->combos[cpos]].tile,x,y,combo->csets[cpos],combobuf[combo->combos[cpos]].flip);
16132 }
16133 }
16134 }
16135 }
16136 }
16137 }
16138
16139 rectfill(screen, d->x-2,d->y-2,d->x+256+2,d->y+176+2,jwin_pal[jcBOX]);
16140 int32_t dx = 120-(combo->width*8)+d->x;
16141 int32_t dy = 80-(combo->height*8)+d->y;
16142 stretch_blit(buf,screen,0,0,(combo->width+1)*16,(combo->height+1)*16,dx,dy,(combo->width+1)*16*size,(combo->height+1)*16*size);
16143 //blit(buf,screen,0,0,120-(combo->width*8)+d->x,80-(combo->height*8)+d->y,(combo->width+1)*16,(combo->height+1)*16);
16144 (d-11)->w = (combo->width+1)*16*size+2;
16145 (d-11)->h = (combo->height+1)*16*size+2;
16146 (d-11)->x = 120-(combo->width*8)+4*size+2+(d-14)->x;
16147 (d-11)->y = 80-(combo->height*8)+25*size+2+(d-14)->y;
16148 object_message((d-11),MSG_DRAW,0);
16149
16150 destroy_bitmap(buf);
16151 }
16152
16153 break;
16154 }
16155
16156 return D_O_K;
16157 }
16158
16159 void draw_combo_alias_thumbnail(BITMAP *dest, combo_alias const* combo, int32_t x, int32_t y, int32_t size)
16160 {
16161 if(!combo->combo)
16162 {
16163 int32_t cur_layer, temp_layer;
16164
16165 int32_t cw=combo->width+1;
16166 int32_t ch=combo->height+1;
16167 int32_t dw=cw<<4;
16168 int32_t dh=ch<<4;
16169 int32_t sw=16, sh=16, sx=0, sy=0;
16170
16171 if(cw<ch)
16172 {
16173 sw=((cw<<4)/ch);
16174 sx=((16-sw)>>1);
16175 }
16176 else
16177 {
16178 sh=((ch<<4)/cw);
16179 sy=((16-sh)>>1);
16180 }
16181
16182 BITMAP *buf = create_bitmap_ex(8,dw,dh);
16183 BITMAP *buf2 = create_bitmap_ex(8, 16*size, 16*size);
16184 clear_bitmap(buf);
16185 clear_bitmap(buf2);
16186
16187 if(buf&&(combo->width>0||combo->height>0||combo->combos[0]>0))
16188 {
16189 clear_bitmap(buf);
16190
16191 for(int32_t z=0; z<=comboa_lmasktotal(combo->layermask); z++)
16192 {
16193 int32_t k=0;
16194 cur_layer=0;
16195 temp_layer=combo->layermask;
16196
16197 while((temp_layer!=0)&&(k<z))
16198 {
16199 if(temp_layer&1)
16200 {
16201 k++;
16202 }
16203
16204 cur_layer++;
16205 temp_layer = temp_layer>>1;
16206 }
16207
16208 for(int32_t y2=0; (y2<dh)&&((y2>>4)<=combo->height); y2+=16)
16209 {
16210 for(int32_t x2=0; (x2<dw)&&((x2>>4)<=combo->width); x2+=16)
16211 {
16212 int32_t cpos = (z*(combo->width+1)*(combo->height+1))+(((y2/16)*(combo->width+1))+(x2/16));
16213
16214 if(combo->combos[cpos])
16215 {
16216 if(z==0)
16217 {
16218 puttile16(buf,combobuf[combo->combos[cpos]].tile,x2,y2,combo->csets[cpos],combobuf[combo->combos[cpos]].flip);
16219 }
16220 else
16221 {
16222 overtile16(buf,combobuf[combo->combos[cpos]].tile,x2,y2,combo->csets[cpos],combobuf[combo->combos[cpos]].flip);
16223 }
16224 }
16225 }
16226 }
16227 }
16228
16229 stretch_blit(buf, buf2, 0, 0, (cw*16), (ch*16), sx*size, sy*size, sw*size, sh*size);
16230 blit(buf2, dest, 0, 0, x, y, 16*size, 16*size);
16231 }
16232 else
16233 {
16234 rectfill(dest,x,y,x+16*size-1,y+16*size-1,0);
16235 rectfill(dest,x+3*size,y+3*size,x+12*size,y+12*size,vc(4));
16236 }
16237
16238 if(buf)
16239 destroy_bitmap(buf);
16240
16241 if(buf2)
16242 destroy_bitmap(buf2);
16243 }
16244 else
16245 {
16246 if(combobuf[combo->combo].tile>0)
16247 {
16248 rectfill(dest,x,y,x+16*size-1,y+16*size-1,0);
16249 put_combo(dest, x, y, combo->combo, combo->cset, 0, 0, size);
16250 }
16251 else
16252 {
16253 rectfill(dest,x,y,x+16*size-1,y+16*size-1,0);
16254 rectfill(dest,x+3*size,y+3*size,x+12*size,y+12*size,vc(4));
16255 }
16256 }
16257 }
16258
16259 int32_t d_comboat_proc(int32_t msg,DIALOG *d,int32_t)
16260 {
16261 switch(msg)
16262 {
16263 case MSG_CLICK:
16264 {
16265 int32_t c2;
16266 int32_t cs;
16267 c2=temp_aliases[comboa_cnt].combo;
16268 cs=temp_aliases[comboa_cnt].cset;
16269
16270 if(gui_mouse_b()&2) //right mouse button
16271 {
16272 if(c2==0&&cs==0&&!(gui_mouse_b()&1))
16273 {
16274 return D_O_K;
16275 }
16276
16277 temp_aliases[comboa_cnt].combo=0;
16278 temp_aliases[comboa_cnt].cset=0;
16279 }
16280
16281 if(gui_mouse_b()&1) //left mouse button
16282 {
16283 if(select_combo_2(c2, cs))
16284 {
16285 temp_aliases[comboa_cnt].combo=c2;
16286 temp_aliases[comboa_cnt].cset=cs;
16287 }
16288
16289 return D_REDRAW;
16290 }
16291 else
16292 {
16293 return D_REDRAWME;
16294 }
16295 }
16296 break;
16297
16298 case MSG_DRAW:
16299 draw_combo_alias_thumbnail(screen, &temp_aliases[comboa_cnt], d->x-1, d->y-1,2);
16300 break;
16301
16302 default:
16303 break;
16304 }
16305
16306 return D_O_K;
16307 }
16308
16309 int32_t d_comboa_radio_proc(int32_t msg,DIALOG *d,int32_t c);
16310
16311 static DIALOG orgcomboa_dlg[] =
16312 {
16313 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
16314 { jwin_win_proc, 0, 0, 200, 161, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Organize Combo Aliases", NULL, NULL },
16315 { jwin_button_proc, 27, 130, 61, 21, vc(14), vc(1), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
16316 { jwin_button_proc, 112, 130, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
16317
16318 { jwin_radio_proc, 10, 40, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void*) "Copy", NULL, NULL },
16319 { jwin_text_proc, 10, 50, 33, 9, 0, 0, 0, 0, 0, 0, (void *) "", NULL, NULL },
16320 // { jwin_radio_proc, 10, 50, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void*) "Move", NULL, NULL },
16321 { jwin_radio_proc, 10, 60, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void*) "Swap", NULL, NULL },
16322 /* 6 */ { jwin_edit_proc, 110, 35, 32, 16, vc(12), vc(1), 0, 0, 4, 0, NULL, NULL, NULL },
16323 { jwin_edit_proc, 110, 55, 32, 16, vc(12), vc(1), 0, 0, 4, 0, NULL, NULL, NULL },
16324 { jwin_text_proc, 60, 40, 80, 8, 0, 0, 0, 0, 0, 0, (void *) "Source", NULL, NULL },
16325 { jwin_text_proc, 60, 60, 80, 8, 0, 0, 0, 0, 0, 0, (void *) "Dest", NULL, NULL},
16326 { jwin_radio_proc, 10, 80, 60, 9, vc(14), vc(1), 0, 0, 0, 0, (void*) "Insert new (before source)", NULL, NULL },
16327 { jwin_radio_proc, 10, 100, 60, 9, vc(14), vc(1), 0, 0, 0, 0, (void*) "Delete source", NULL, NULL },
16328 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
16329 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
16330 };
16331
16332 static DIALOG newcomboa_dlg[] =
16333 {
16334 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
16335 { jwin_win_proc, 0, 0, 200, 161, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Combo Alias Properties", NULL, NULL },
16336 { jwin_button_proc, 27, 130, 61, 21, vc(14), vc(1), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
16337 { jwin_button_proc, 112, 130, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
16338 { jwin_text_proc, 24, 34, 80, 8, 0, 0, 0, 0, 0, 0, (void *) "Alias Width", NULL, NULL },
16339 { jwin_text_proc, 24, 52, 80, 8, 0, 0, 0, 0, 0, 0, (void *) "Alias Height", NULL, NULL },
16340 { jwin_text_proc, 24, 70, 100, 8, 0, 0, 0, 0, 0, 0, (void *) "Layers to Draw On:", NULL, NULL },
16341 { jwin_edit_proc, 104, 30, 28-6, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
16342 { jwin_edit_proc, 122, 48, 28-6, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
16343 { jwin_check_proc, 24, 86, 24, 9, vc(12), vc(1), 0, 0, 1, 0, (void *) "1", NULL, NULL },
16344 { jwin_check_proc, 50, 86, 24, 9, vc(12), vc(1), 0, 0, 1, 0, (void *) "2", NULL, NULL },
16345 { jwin_check_proc, 76, 86, 24, 9, vc(12), vc(1), 0, 0, 1, 0, (void *) "3", NULL, NULL },
16346 { jwin_check_proc, 102, 86, 24, 9, vc(12), vc(1), 0, 0, 1, 0, (void *) "4", NULL, NULL },
16347 { jwin_check_proc, 128, 86, 24, 9, vc(12), vc(1), 0, 0, 1, 0, (void *) "5", NULL, NULL },
16348 { jwin_check_proc, 154, 86, 24, 9, vc(12), vc(1), 0, 0, 1, 0, (void *) "6", NULL, NULL },
16349
16350
16351 // { jwin_text_proc, 24, 106, 80, 8, 0, 0, 0, 0, 0, 0, (void *) "Copy to :", NULL, NULL },
16352 //15
16353 // { jwin_edit_proc, 100, 100, 28-6, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
16354 // { jwin_check_proc, 84, 106, 24, 9, vc(12), vc(1), 0, 0, 1, 0, (void *) "", NULL, NULL },
16355
16356 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
16357 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
16358 };
16359
16360 bool swapComboAlias(int32_t source, int32_t dest)
16361 {
16362 if(source==dest)
16363 return false;
16364 zc_swap(temp_aliases[source],temp_aliases[dest]);
16365 return true;
16366 }
16367
16368
16369 bool copyComboAlias(int32_t source, int32_t dest)
16370 {
16371 if(source == dest)
16372 return false;
16373 temp_aliases[dest] = temp_aliases[source];
16374 return true;
16375 }
16376
16377 int32_t getcurrentcomboalias();
16378
16379 int32_t onOrgComboAliases()
16380 {
16381 char cSrc[8];
16382 char cDest[8];
16383 sprintf(cSrc,"%d", getcurrentcomboalias());
16384 strcpy(cDest,cSrc);
16385 int32_t iSrc = 0;
16386 int32_t iDest = 0;
16387
16388 //sprintf(cSrc,"0");
16389 //sprintf(cDest,"0");
16390 orgcomboa_dlg[0].dp2=get_zc_font(font_lfont);
16391 orgcomboa_dlg[6].dp= cSrc;
16392 orgcomboa_dlg[7].dp= cDest;
16393 int32_t ret = 1;
16394 large_dialog(orgcomboa_dlg);
16395 do
16396 {
16397 iSrc = atoi((char*)orgcomboa_dlg[6].dp);
16398 iDest = atoi((char*)orgcomboa_dlg[7].dp);
16399 ret = do_zqdialog(orgcomboa_dlg,-1);
16400
16401 if(ret!=1) return ret;
16402
16403 if((atoi((char*) orgcomboa_dlg[6].dp))<0 || (atoi((char*) orgcomboa_dlg[6].dp)) > MAXCOMBOALIASES-1)
16404 {
16405 char buf[100];
16406 snprintf(buf, 100, "Invalid source (range 0-%d)", MAXCOMBOALIASES-1);
16407 buf[99]='\0';
16408 jwin_alert("Error",buf,NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
16409 ret = 1;
16410 }
16411
16412 // 10,11=ins, del
16413 if(orgcomboa_dlg[10].flags & D_SELECTED) //insert
16414 {
16415 for(int32_t j=MAXCOMBOALIASES-1; j>(atoi((char*) orgcomboa_dlg[6].dp)); --j)
16416 copyComboAlias(j-1,j);
16417 ret = -1;
16418 }
16419
16420 if(orgcomboa_dlg[11].flags & D_SELECTED) //delete
16421 {
16422 for(int32_t j=(atoi((char*) orgcomboa_dlg[6].dp)); j<MAXCOMBOALIASES-1; ++j)
16423 copyComboAlias(j+1,j);
16424 ret = -1;
16425 }
16426
16427 if((atoi((char*) orgcomboa_dlg[6].dp)) == (atoi((char*) orgcomboa_dlg[7].dp)))
16428 {
16429 jwin_alert("Error","Source and dest can't be the same.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
16430 ret = 1;
16431 }
16432
16433 if((atoi((char*) orgcomboa_dlg[7].dp)) < 0 || (atoi((char*) orgcomboa_dlg[7].dp)) > MAXCOMBOALIASES-1)
16434 {
16435 char buf[100];
16436 snprintf(buf, 100, "Invalid dest (range 0-%d)", MAXCOMBOALIASES-1);
16437 buf[99]='\0';
16438
16439 jwin_alert("Error",buf,NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
16440 ret = 1;
16441 }
16442
16443 if(orgcomboa_dlg[3].flags & D_SELECTED) //copy
16444 {
16445 copyComboAlias((atoi((char*) orgcomboa_dlg[6].dp)),(atoi((char*) orgcomboa_dlg[7].dp)));
16446 ret = -1;
16447 }
16448
16449 if(orgcomboa_dlg[5].flags & D_SELECTED) //swap
16450 {
16451 swapComboAlias((atoi((char*) orgcomboa_dlg[6].dp)),(atoi((char*) orgcomboa_dlg[7].dp)));
16452 ret = -1;
16453 }
16454 }
16455 while(ret==1);
16456 return ret;
16457 }
16458
16459 int32_t onNewComboAlias()
16460 {
16461 combo_alias *combo;
16462 combo = &temp_aliases[comboa_cnt];
16463
16464 char cwidth[5];
16465 char cheight[5];
16466 // char cp[3];
16467
16468 word temp_combos[16*11*7];
16469 byte temp_csets[16*11*7];
16470 sprintf(cwidth, "%d", combo->width+1);
16471 sprintf(cheight, "%d", combo->height+1);
16472 int32_t old_count = (comboa_lmasktotal(combo->layermask)+1)*(combo->width+1)*(combo->height+1);
16473 int32_t old_width=combo->width;
16474 int32_t old_height=combo->height;
16475 int32_t oldlayer=combo->layermask;
16476
16477 for(int32_t i=0; i<old_count; i++)
16478 {
16479 temp_csets[i] = combo->csets[i];
16480 temp_combos[i] = combo->combos[i];
16481 }
16482
16483 newcomboa_dlg[0].dp2 = get_zc_font(font_lfont);
16484 newcomboa_dlg[6].dp = cwidth;
16485 newcomboa_dlg[7].dp = cheight;
16486 newcomboa_dlg[8].flags = (combo->layermask&1)? D_SELECTED : 0;
16487 newcomboa_dlg[9].flags = (combo->layermask&2)? D_SELECTED : 0;
16488 newcomboa_dlg[10].flags = (combo->layermask&4)? D_SELECTED : 0;
16489 newcomboa_dlg[11].flags = (combo->layermask&8)? D_SELECTED : 0;
16490 newcomboa_dlg[12].flags = (combo->layermask&16)? D_SELECTED : 0;
16491 newcomboa_dlg[13].flags = (combo->layermask&32)? D_SELECTED : 0;
16492
16493 large_dialog(newcomboa_dlg);
16494
16495 int32_t ret = do_zqdialog(newcomboa_dlg,-1);
16496
16497 if(ret==1)
16498 {
16499 combo->width = ((atoi(cwidth)-1)<16)?zc_max(0,(atoi(cwidth)-1)):15;
16500 combo->height = ((atoi(cheight)-1)<11)?zc_max(0,(atoi(cheight)-1)):10;
16501 combo->layermask=0;
16502 combo->layermask |= (newcomboa_dlg[8].flags&D_SELECTED)?1:0;
16503 combo->layermask |= (newcomboa_dlg[9].flags&D_SELECTED)?2:0;
16504 combo->layermask |= (newcomboa_dlg[10].flags&D_SELECTED)?4:0;
16505 combo->layermask |= (newcomboa_dlg[11].flags&D_SELECTED)?8:0;
16506 combo->layermask |= (newcomboa_dlg[12].flags&D_SELECTED)?16:0;
16507 combo->layermask |= (newcomboa_dlg[13].flags&D_SELECTED)?32:0;
16508
16509 int32_t new_count = (comboa_lmasktotal(combo->layermask)+1)*(combo->width+1)*(combo->height+1);
16510
16511 combo->combos.clear();
16512 combo->csets.clear();
16513
16514 int32_t j=1;
16515 int32_t old_size=(old_width+1)*(old_height+1);
16516 int32_t new_start[7] =
16517 {
16518 0,
16519 ((combo->width+1)*(combo->height+1)*(1)),
16520 ((combo->width+1)*(combo->height+1)*(2)),
16521 ((combo->width+1)*(combo->height+1)*(3)),
16522 ((combo->width+1)*(combo->height+1)*(4)),
16523 ((combo->width+1)*(combo->height+1)*(5)),
16524 ((combo->width+1)*(combo->height+1)*(6))
16525 };
16526 int32_t new_layers[6] = {0,0,0,0,0,0};
16527 int32_t temp_layer = combo->layermask;
16528 int32_t temp_old = oldlayer;
16529 int32_t old_layers[6] = {0,0,0,0,0,0};
16530 int32_t k=1;
16531
16532 for(int32_t i=0; (i<6)&&(temp_layer!=0); j++,temp_layer>>=1,temp_old>>=1)
16533 {
16534 if(temp_layer&1)
16535 {
16536 new_layers[i] = j;
16537 //if(oldlayer&(1<<(j-1))) old_layers[i] = k++;
16538 i++;
16539 }
16540
16541 if(temp_old&1)
16542 {
16543 if(temp_layer&1)
16544 {
16545 old_layers[i-1] = k;
16546 }
16547
16548 k++;
16549 }
16550 }
16551
16552 for(int32_t i=0; i<new_count; i++)
16553 {
16554 if(i>=new_start[6])
16555 {
16556 //oldl=oldlayer>>(new_layers[5]-1);
16557 j=i-new_start[6];
16558
16559 if(((j/(combo->width+1))<=old_height)&&((j%(combo->width+1))<=old_width)&&(oldlayer&(1<<(new_layers[5]-1))))
16560 {
16561 combo->combos[i] = temp_combos[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[5])];
16562 combo->csets[i] = temp_csets[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[5])];
16563 }
16564 else
16565 {
16566 combo->combos[i] = 0;
16567 combo->csets[i] = 0;
16568 }
16569 }
16570 else if(i>=new_start[5])
16571 {
16572 //oldl=oldlayer>>(new_layers[4]-1);
16573 j=i-new_start[5];
16574
16575 if(((j/(combo->width+1))<=old_height)&&((j%(combo->width+1))<=old_width)&&(oldlayer&(1<<(new_layers[4]-1))))
16576 {
16577 combo->combos[i] = temp_combos[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[4])];
16578 combo->csets[i] = temp_csets[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[4])];
16579 }
16580 else
16581 {
16582 combo->combos[i] = 0;
16583 combo->csets[i] = 0;
16584 }
16585 }
16586 else if(i>=new_start[4])
16587 {
16588 //oldl=oldlayer>>(new_layers[3]-1);
16589 j=i-new_start[4];
16590
16591 if(((j/(combo->width+1))<=old_height)&&((j%(combo->width+1))<=old_width)&&(oldlayer&(1<<(new_layers[3]-1))))
16592 {
16593 combo->combos[i] = temp_combos[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[3])];
16594 combo->csets[i] = temp_csets[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[3])];
16595 }
16596 else
16597 {
16598 combo->combos[i] = 0;
16599 combo->csets[i] = 0;
16600 }
16601 }
16602 else if(i>=new_start[3])
16603 {
16604 //oldl=oldlayer>>(new_layers[2]-1);
16605 j=i-new_start[3];
16606
16607 if(((j/(combo->width+1))<=old_height)&&((j%(combo->width+1))<=old_width)&&(oldlayer&(1<<(new_layers[2]-1))))
16608 {
16609 combo->combos[i] = temp_combos[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[2])];
16610 combo->csets[i] = temp_csets[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[2])];
16611 }
16612 else
16613 {
16614 combo->combos[i] = 0;
16615 combo->csets[i] = 0;
16616 }
16617 }
16618 else if(i>=new_start[2])
16619 {
16620 //oldl=oldlayer>>(new_layers[1]-1);
16621 j=i-new_start[2];
16622
16623 if(((j/(combo->width+1))<=old_height)&&((j%(combo->width+1))<=old_width)&&(oldlayer&(1<<(new_layers[1]-1))))
16624 {
16625 combo->combos[i] = temp_combos[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[1])];
16626 combo->csets[i] = temp_csets[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[1])];
16627 }
16628 else
16629 {
16630 combo->combos[i] = 0;
16631 combo->csets[i] = 0;
16632 }
16633 }
16634 else if(i>=new_start[1])
16635 {
16636 //oldl=oldlayer>>(new_layers[0]-1);
16637 j=i-new_start[1];
16638
16639 if(((j/(combo->width+1))<=old_height)&&((j%(combo->width+1))<=old_width)&&(oldlayer&(1<<(new_layers[0]-1))))
16640 {
16641 combo->combos[i] = temp_combos[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[0])];
16642 combo->csets[i] = temp_csets[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[0])];
16643 }
16644 else
16645 {
16646 combo->combos[i] = 0;
16647 combo->csets[i] = 0;
16648 }
16649 }
16650 else if(i>=new_start[0])
16651 {
16652 if(((i/(combo->width+1))<=old_height)&&((i%(combo->width+1))<=old_width))
16653 {
16654 combo->combos[i] = temp_combos[(i%(combo->width+1))+((old_width+1)*(i/(combo->width+1)))];
16655 combo->csets[i] = temp_csets[(i%(combo->width+1))+((old_width+1)*(i/(combo->width+1)))];
16656 }
16657 else
16658 {
16659 combo->combos[i] = 0;
16660 combo->csets[i] = 0;
16661 }
16662 }
16663 }
16664
16665 set_comboaradio(combo->layermask);
16666 }
16667
16668 return ret;
16669 }
16670
16671 int32_t d_orgcomboa_proc(int32_t msg, DIALOG *d, int32_t c)
16672 {
16673 //these are here to bypass compiler warnings about unused arguments
16674 c=c;
16675
16676 int32_t down=0;
16677 int32_t selected=(d->flags&D_SELECTED)?1:0;
16678 int32_t last_draw;
16679
16680 switch(msg)
16681 {
16682
16683 case MSG_DRAW:
16684 {
16685 FONT *tfont=font;
16686 font=get_zc_font(font_lfont_l);
16687 jwin_draw_text_button(screen, d->x, d->y, d->w, d->h, (char*)d->dp, d->flags, true);
16688 font=tfont;
16689 }
16690 break;
16691
16692 case MSG_WANTFOCUS:
16693 return D_WANTFOCUS;
16694
16695 case MSG_KEY:
16696 /* close dialog? */
16697 onOrgComboAliases();
16698 return D_REDRAW;
16699
16700 /* or just toggle */
16701 /*d->flags ^= D_SELECTED;
16702 object_message(d, MSG_DRAW, 0);
16703 break;*/
16704
16705 case MSG_CLICK:
16706 last_draw = 0;
16707
16708 /* track the mouse until it is released */
16709 while(gui_mouse_b())
16710 {
16711 down = mouse_in_rect(d->x, d->y, d->w, d->h);
16712
16713 /* redraw? */
16714 if(last_draw != down)
16715 {
16716 if(down != selected)
16717 d->flags |= D_SELECTED;
16718 else
16719 d->flags &= ~D_SELECTED;
16720
16721 object_message(d, MSG_DRAW, 0);
16722 last_draw = down;
16723 }
16724
16725 /* let other objects continue to animate */
16726 broadcast_dialog_message(MSG_IDLE, 0);
16727 }
16728
16729 /* redraw in normal state */
16730 if(down)
16731 {
16732 if(d->flags&D_EXIT)
16733 {
16734 d->flags &= ~D_SELECTED;
16735 object_message(d, MSG_DRAW, 0);
16736 }
16737 }
16738
16739 /* should we close the dialog? */
16740 if(down)
16741 {
16742 onOrgComboAliases();
16743 return D_REDRAW;
16744 }
16745
16746 break;
16747 }
16748
16749 return D_O_K;
16750 }
16751
16752 int32_t d_comboabutton_proc(int32_t msg, DIALOG *d, int32_t c)
16753 {
16754 //these are here to bypass compiler warnings about unused arguments
16755 c=c;
16756
16757 int32_t down=0;
16758 int32_t selected=(d->flags&D_SELECTED)?1:0;
16759 int32_t last_draw;
16760
16761 switch(msg)
16762 {
16763
16764 case MSG_DRAW:
16765 {
16766 FONT *tfont=font;
16767 font=get_zc_font(font_lfont_l);
16768 jwin_draw_text_button(screen, d->x, d->y, d->w, d->h, (char*)d->dp, d->flags, true);
16769 font=tfont;
16770 }
16771 break;
16772
16773 case MSG_WANTFOCUS:
16774 return D_WANTFOCUS;
16775
16776 case MSG_KEY:
16777 /* close dialog? */
16778 onNewComboAlias();
16779 return D_REDRAW;
16780
16781 /* or just toggle */
16782 /*d->flags ^= D_SELECTED;
16783 object_message(d, MSG_DRAW, 0);
16784 break;*/
16785
16786 case MSG_CLICK:
16787 last_draw = 0;
16788
16789 /* track the mouse until it is released */
16790 while(gui_mouse_b())
16791 {
16792 down = mouse_in_rect(d->x, d->y, d->w, d->h);
16793
16794 /* redraw? */
16795 if(last_draw != down)
16796 {
16797 if(down != selected)
16798 d->flags |= D_SELECTED;
16799 else
16800 d->flags &= ~D_SELECTED;
16801
16802 object_message(d, MSG_DRAW, 0);
16803 last_draw = down;
16804 }
16805
16806 /* let other objects continue to animate */
16807 broadcast_dialog_message(MSG_IDLE, 0);
16808 }
16809
16810 /* redraw in normal state */
16811 if(down)
16812 {
16813 if(d->flags&D_EXIT)
16814 {
16815 d->flags &= ~D_SELECTED;
16816 object_message(d, MSG_DRAW, 0);
16817 }
16818 }
16819
16820 /* should we close the dialog? */
16821 if(down)
16822 {
16823 onNewComboAlias();
16824 return D_REDRAW;
16825 }
16826
16827 break;
16828 }
16829
16830 return D_O_K;
16831 }
16832
16833 int32_t d_comboacheck_proc(int32_t msg, DIALOG *d, int32_t c)
16834 {
16835 int32_t temp = d->flags&D_SELECTED;
16836 int32_t ret=jwin_checkfont_proc(msg,d,c);
16837
16838 if(temp != (d->flags&D_SELECTED))
16839 {
16840 return D_REDRAW;
16841 }
16842
16843 return ret;
16844 }
16845
16846 static DIALOG editcomboa_dlg[] =
16847 {
16848 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
16849 { jwin_win_proc, 0, 0, 320, 240, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Combo Alias Edit", NULL, NULL },
16850 { jwin_button_proc, 148, 212, 61, 21, vc(14), vc(1), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
16851 { jwin_button_proc, 232, 212, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
16852 { jwin_frame_proc, 4+121, 28+81, 1, 1, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
16853 { d_comboabutton_proc, 25, 212, 81, 21, vc(14), vc(1), 'p', D_EXIT, 0, 0, (void *) "&Properties", NULL, NULL },
16854 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
16855 { d_comboa_radio_proc, 285, 44, 30, 8+1, vc(14), vc(1), 0, D_SELECTED, 0, 0, (void *) "0", NULL, NULL },
16856 { d_comboa_radio_proc, 285, 54, 30, 8+1, vc(14), vc(1), 0, 0, 0, 0, (void *) "1", NULL, NULL },
16857 { d_comboa_radio_proc, 285, 64, 30, 8+1, vc(14), vc(1), 0, 0, 0, 0, (void *) "2", NULL, NULL },
16858 { d_comboa_radio_proc, 285, 74, 30, 8+1, vc(14), vc(1), 0, 0, 0, 0, (void *) "3", NULL, NULL },
16859 { d_comboa_radio_proc, 285, 84, 30, 8+1, vc(14), vc(1), 0, 0, 0, 0, (void *) "4", NULL, NULL },
16860
16861 { d_comboa_radio_proc, 285, 94, 30, 8+1, vc(14), vc(1), 0, 0, 0, 0, (void *) "5", NULL, NULL },
16862 { d_comboa_radio_proc, 285, 104, 30, 8+1, vc(14), vc(1), 0, 0, 0, 0, (void *) "6", NULL, NULL },
16863 { d_comboacheck_proc, 285, 164, 17, 9, vc(12), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
16864 { d_comboa_proc, 6, 27, 256, 176, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
16865 { jwin_ctext_proc, 290, 176, 27, 8, 0, 0, 0, 0, 0, 0, (void *) "Only Show", NULL, NULL },
16866 { jwin_ctext_proc, 290, 186, 27, 8, 0, 0, 0, 0, 0, 0, (void *) "Current", NULL, NULL },
16867 { jwin_ctext_proc, 290, 196, 27, 8, 0, 0, 0, 0, 0, 0, (void *) "Layer", NULL, NULL },
16868 { jwin_ctext_proc, 290, 122, 27, 8, 0, 0, 0, 0, 0, 0, (void *) "Thumbnail", NULL, NULL },
16869 { jwin_frame_proc, 280, 132, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
16870 { d_comboat_proc, 282, 134, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
16871
16872 //21
16873 { d_orgcomboa_proc, 106, 212, 21, 21, vc(14), vc(1), 'p', D_EXIT, 0, 0, (void *) "&Org", NULL, NULL },
16874 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
16875 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
16876 };
16877
16878 int32_t getcurrentcomboalias()
16879 {
16880 return editcomboa_dlg[5].d1;
16881 }
16882
16883 int32_t d_comboa_radio_proc(int32_t msg,DIALOG *d,int32_t c)
16884 {
16885 int32_t temp = layer_cnt;
16886 int32_t ret = jwin_radiofont_proc(msg,d,c);
16887
16888 if(editcomboa_dlg[6].flags&D_SELECTED) layer_cnt=0;
16889 else if(editcomboa_dlg[7].flags&D_SELECTED) layer_cnt=1;
16890 else if(editcomboa_dlg[8].flags&D_SELECTED) layer_cnt=2;
16891 else if(editcomboa_dlg[9].flags&D_SELECTED) layer_cnt=3;
16892 else if(editcomboa_dlg[10].flags&D_SELECTED) layer_cnt=4;
16893 else if(editcomboa_dlg[11].flags&D_SELECTED) layer_cnt=5;
16894 else if(editcomboa_dlg[12].flags&D_SELECTED) layer_cnt=6;
16895
16896 if(temp != layer_cnt)
16897 {
16898 return D_REDRAW;
16899 }
16900
16901 return ret;
16902 }
16903
16904 int32_t set_comboaradio(byte layermask)
16905 {
16906 if(editcomboa_dlg[7].flags&D_SELECTED) editcomboa_dlg[7].flags &= ~D_SELECTED;
16907
16908 if(editcomboa_dlg[8].flags&D_SELECTED) editcomboa_dlg[8].flags &= ~D_SELECTED;
16909
16910 if(editcomboa_dlg[9].flags&D_SELECTED) editcomboa_dlg[9].flags &= ~D_SELECTED;
16911
16912 if(editcomboa_dlg[10].flags&D_SELECTED) editcomboa_dlg[10].flags &= ~D_SELECTED;
16913
16914 if(editcomboa_dlg[11].flags&D_SELECTED) editcomboa_dlg[11].flags &= ~D_SELECTED;
16915
16916 if(editcomboa_dlg[12].flags&D_SELECTED) editcomboa_dlg[12].flags &= ~D_SELECTED;
16917
16918 if(!(layermask&1)) editcomboa_dlg[7].flags |= D_DISABLED;
16919 else editcomboa_dlg[7].flags &= ~D_DISABLED;
16920
16921 if(!(layermask&2)) editcomboa_dlg[8].flags |= D_DISABLED;
16922 else editcomboa_dlg[8].flags &= ~D_DISABLED;
16923
16924 if(!(layermask&4)) editcomboa_dlg[9].flags |= D_DISABLED;
16925 else editcomboa_dlg[9].flags &= ~D_DISABLED;
16926
16927 if(!(layermask&8)) editcomboa_dlg[10].flags |= D_DISABLED;
16928 else editcomboa_dlg[10].flags &= ~D_DISABLED;
16929
16930 if(!(layermask&16)) editcomboa_dlg[11].flags |= D_DISABLED;
16931 else editcomboa_dlg[11].flags &= ~D_DISABLED;
16932
16933 if(!(layermask&32)) editcomboa_dlg[12].flags |= D_DISABLED;
16934 else editcomboa_dlg[12].flags &= ~D_DISABLED;
16935
16936 editcomboa_dlg[6].flags |= D_SELECTED;
16937 layer_cnt=0;
16938 return 1;
16939 }
16940
16941 int32_t onEditComboPool()
16942 {
16943 call_cpool_dlg(combo_pool_pos);
16944 return D_O_K;
16945 }
16946 int32_t onEditAutoCombo()
16947 {
16948 call_autocombo_dlg(combo_auto_pos);
16949 return D_O_K;
16950 }
16951 int32_t onEditComboAlias()
16952 {
16953 comboa_cnt = combo_apos;
16954 reset_combo_animations();
16955 reset_combo_animations2();
16956
16957 for(int32_t i=0; i<MAXCOMBOALIASES; i++)
16958 temp_aliases[i] = combo_aliases[i];
16959
16960 editcomboa_dlg[0].dp2 = get_zc_font(font_lfont);
16961 set_comboaradio(temp_aliases[comboa_cnt].layermask);
16962 editcomboa_dlg[5].d1 = comboa_cnt;
16963
16964 bool small_d1 = editcomboa_dlg[0].d1==0;
16965 large_dialog(editcomboa_dlg,2);
16966
16967 if(small_d1)
16968 {
16969 for(int32_t i=6; i<=12; i++)
16970 {
16971 editcomboa_dlg[i].w=30*1.5;
16972 editcomboa_dlg[i].h=9*1.5;
16973 }
16974
16975 editcomboa_dlg[13].w=17*1.5;
16976 editcomboa_dlg[13].h=9*1.5;
16977 editcomboa_dlg[4].w=81*1.5;
16978 editcomboa_dlg[4].h=21*1.5;
16979 editcomboa_dlg[4].dp2=get_zc_font(font_lfont_l);
16980 editcomboa_dlg[21].w=21*1.5;
16981 editcomboa_dlg[21].h=21*1.5;
16982 editcomboa_dlg[21].dp2=get_zc_font(font_lfont_l);
16983 }
16984
16985 int32_t ret=do_zqdialog(editcomboa_dlg,-1);
16986
16987 if(ret==1)
16988 {
16989 mark_save_dirty();
16990
16991 for(int32_t i=0; i<MAXCOMBOALIASES; i++)
16992 combo_aliases[i] = temp_aliases[i];
16993 }
16994
16995 setup_combo_animations();
16996 setup_combo_animations2();
16997 return D_O_K;
16998 }
16999 void call_calias_dlg(int index)
17000 {
17001 combo_apos = comboa_cnt = index;
17002 onEditComboAlias();
17003 }
17004
17005 int32_t onSelectFFCombo()
17006 {
17007 FFCListerDialog().show();
17008 return D_O_K;
17009 }
17010
17011 static int32_t as_ffc_list[] = { 4, 5, 6, -1};
17012 static int32_t as_global_list[] = { 7, 8, 9, -1}; //Why does putting 15 in here not place my message only on the global tab? ~Joe
17013 static int32_t as_item_list[] = { 10, 11, 12, -1};
17014 static int32_t as_npc_list[] = { 18, 19, 20, -1}; //npc scripts TAB
17015 static int32_t as_lweapon_list[] = { 21, 22, 23, -1}; //lweapon scripts TAB
17016 static int32_t as_eweapon_list[] = { 24, 25, 26, -1}; //eweapon scripts TAB
17017 static int32_t as_hero_list[] = { 27, 28, 29, -1}; //hero scripts TAB
17018 static int32_t as_screen_list[] = { 30, 31, 32, -1}; //screendata scripts TAB
17019 static int32_t as_dmap_list[] = { 33, 34, 35, -1}; //dmapdata scripts TAB
17020 static int32_t as_itemsprite_list[] = { 36, 37, 38, -1}; //dmapdata scripts TAB
17021 static int32_t as_comboscript_list[] = { 39, 40, 41, -1}; //combodata scripts TAB
17022 static int32_t as_genericscript_list[] = { 45, 46, 47, -1}; //generic scripts TAB
17023 static int32_t as_subscreenscript_list[] = { 48, 49, 50, -1}; //generic scripts TAB
17024
17025 static TABPANEL assignscript_tabs[] =
17026 {
17027 // (text)
17028 { (char *)"FFC", D_SELECTED, as_ffc_list, 0, NULL },
17029 { (char *)"Global", 0, as_global_list, 0, NULL },
17030 { (char *)"Item", 0, as_item_list, 0, NULL },
17031 { (char *)"NPC", 0, as_npc_list, 0, NULL },
17032 { (char *)"LWeapon", 0, as_lweapon_list, 0, NULL },
17033 { (char *)"EWeapon", 0, as_eweapon_list, 0, NULL },
17034 { (char *)"Hero", 0, as_hero_list, 0, NULL },
17035 { (char *)"DMap", 0, as_dmap_list, 0, NULL },
17036 { (char *)"Screen", 0, as_screen_list, 0, NULL },
17037 { (char *)"Item Sprite", 0, as_itemsprite_list, 0, NULL },
17038 { (char *)"Combo", 0, as_comboscript_list, 0, NULL },
17039 { (char *)"Generic", 0, as_genericscript_list, 0, NULL },
17040 { (char *)"Subscreen", 0, as_subscreenscript_list, 0, NULL },
17041 { NULL, 0, NULL, 0, NULL }
17042 };
17043
17044 const char *assignffclist(int32_t index, int32_t *list_size)
17045 {
17046 if(index<0)
17047 {
17048 *list_size = (int32_t)ffcmap.size();
17049 return NULL;
17050 }
17051
17052 return ffcmap[index].output.c_str();
17053 }
17054
17055 const char *assigngloballist(int32_t index, int32_t *list_size)
17056 {
17057 if(index<0)
17058 {
17059 *list_size = (int32_t)globalmap.size();
17060 return NULL;
17061 }
17062
17063 return globalmap[index].output.c_str();
17064 }
17065
17066 const char *assigncombolist(int32_t index, int32_t *list_size)
17067 {
17068 if(index<0)
17069 {
17070 *list_size = (int32_t)comboscriptmap.size();
17071 return NULL;
17072 }
17073
17074 return comboscriptmap[index].output.c_str();
17075 }
17076
17077 const char *assigngenericlist(int32_t index, int32_t *list_size)
17078 {
17079 if(index<0)
17080 {
17081 *list_size = ((int32_t)genericmap.size());
17082 return NULL;
17083 }
17084
17085 return genericmap[index].output.c_str();
17086 }
17087
17088 const char *assignsubscreenlist(int32_t index, int32_t *list_size)
17089 {
17090 if(index<0)
17091 {
17092 *list_size = ((int32_t)subscreenmap.size());
17093 return NULL;
17094 }
17095
17096 return subscreenmap[index].output.c_str();
17097 }
17098
17099 const char *assignitemlist(int32_t index, int32_t *list_size)
17100 {
17101 if(index<0)
17102 {
17103 *list_size = (int32_t)itemmap.size();
17104 return NULL;
17105 }
17106
17107 return itemmap[index].output.c_str();
17108 }
17109 const char *assignnpclist(int32_t index, int32_t *list_size)
17110 {
17111 if(index<0)
17112 {
17113 *list_size = (int32_t)npcmap.size();
17114 return NULL;
17115 }
17116
17117 return npcmap[index].output.c_str();
17118 }
17119
17120 const char *assignlweaponlist(int32_t index, int32_t *list_size)
17121 {
17122 if(index<0)
17123 {
17124 *list_size = (int32_t)lwpnmap.size();
17125 return NULL;
17126 }
17127
17128 return lwpnmap[index].output.c_str();
17129 }
17130
17131 const char *assigneweaponlist(int32_t index, int32_t *list_size)
17132 {
17133 if(index<0)
17134 {
17135 *list_size = (int32_t)ewpnmap.size();
17136 return NULL;
17137 }
17138
17139 return ewpnmap[index].output.c_str();
17140 }
17141
17142 const char *assignplayerlist(int32_t index, int32_t *list_size)
17143 {
17144 if(index<0)
17145 {
17146 *list_size = (int32_t)playermap.size();
17147 return NULL;
17148 }
17149
17150 return playermap[index].output.c_str();
17151 }
17152
17153 const char *assigndmaplist(int32_t index, int32_t *list_size)
17154 {
17155 if(index<0)
17156 {
17157 *list_size = (int32_t)dmapmap.size();
17158 return NULL;
17159 }
17160
17161 return dmapmap[index].output.c_str();
17162 }
17163
17164 const char *assignscreenlist(int32_t index, int32_t *list_size)
17165 {
17166 if(index<0)
17167 {
17168 *list_size = (int32_t)screenmap.size();
17169 return NULL;
17170 }
17171
17172 return screenmap[index].output.c_str();
17173 }
17174
17175 const char *assignitemspritelist(int32_t index, int32_t *list_size)
17176 {
17177 if(index<0)
17178 {
17179 *list_size = (int32_t)itemspritemap.size();
17180 return NULL;
17181 }
17182
17183 return itemspritemap[index].output.c_str();
17184 }
17185
17186 const char *assignffcscriptlist(int32_t index, int32_t *list_size)
17187 {
17188 if(index<0)
17189 {
17190 *list_size = (int32_t)asffcscripts.size();
17191 return NULL;
17192 }
17193
17194 return asffcscripts[index].c_str();
17195 }
17196
17197 const char *assignglobalscriptlist(int32_t index, int32_t *list_size)
17198 {
17199 if(index<0)
17200 {
17201 *list_size = (int32_t)asglobalscripts.size();
17202 return NULL;
17203 }
17204
17205 return asglobalscripts[index].c_str();
17206 }
17207
17208 const char *assignitemscriptlist(int32_t index, int32_t *list_size)
17209 {
17210 if(index<0)
17211 {
17212 *list_size = (int32_t)asitemscripts.size();
17213 return NULL;
17214 }
17215
17216 return asitemscripts[index].c_str();
17217 }
17218
17219 const char *assignnpcscriptlist(int32_t index, int32_t *list_size)
17220 {
17221 if(index<0)
17222 {
17223 *list_size = (int32_t)asnpcscripts.size();
17224 return NULL;
17225 }
17226
17227 return asnpcscripts[index].c_str();
17228 }
17229
17230 const char *assignlweaponscriptlist(int32_t index, int32_t *list_size)
17231 {
17232 if(index<0)
17233 {
17234 *list_size = (int32_t)aslweaponscripts.size();
17235 return NULL;
17236 }
17237
17238 return aslweaponscripts[index].c_str();
17239 }
17240
17241 const char *assigneweaponscriptlist(int32_t index, int32_t *list_size)
17242 {
17243 if(index<0)
17244 {
17245 *list_size = (int32_t)aseweaponscripts.size();
17246 return NULL;
17247 }
17248
17249 return aseweaponscripts[index].c_str();
17250 }
17251
17252 const char *assignplayerscriptlist(int32_t index, int32_t *list_size)
17253 {
17254 if(index<0)
17255 {
17256 *list_size = (int32_t)asplayerscripts.size();
17257 return NULL;
17258 }
17259
17260 return asplayerscripts[index].c_str();
17261 }
17262
17263 const char *assigndmapscriptlist(int32_t index, int32_t *list_size)
17264 {
17265 if(index<0)
17266 {
17267 *list_size = (int32_t)asdmapscripts.size();
17268 return NULL;
17269 }
17270
17271 return asdmapscripts[index].c_str();
17272 }
17273
17274 const char *assignscreenscriptlist(int32_t index, int32_t *list_size)
17275 {
17276 if(index<0)
17277 {
17278 *list_size = (int32_t)asscreenscripts.size();
17279 return NULL;
17280 }
17281
17282 return asscreenscripts[index].c_str();
17283 }
17284
17285 const char *assignitemspritescriptlist(int32_t index, int32_t *list_size)
17286 {
17287 if(index<0)
17288 {
17289 *list_size = (int32_t)asitemspritescripts.size();
17290 return NULL;
17291 }
17292
17293 return asitemspritescripts[index].c_str();
17294 }
17295
17296 const char *assigncomboscriptlist(int32_t index, int32_t *list_size)
17297 {
17298 if(index<0)
17299 {
17300 *list_size = (int32_t)ascomboscripts.size();
17301 return NULL;
17302 }
17303
17304 return ascomboscripts[index].c_str();
17305 }
17306
17307 const char *assigngenericscriptlist(int32_t index, int32_t *list_size)
17308 {
17309 if(index<0)
17310 {
17311 *list_size = (int32_t)asgenericscripts.size();
17312 return NULL;
17313 }
17314
17315 return asgenericscripts[index].c_str();
17316 }
17317
17318 const char *assignsubscreenscriptlist(int32_t index, int32_t *list_size)
17319 {
17320 if(index<0)
17321 {
17322 *list_size = (int32_t)assubscreenscripts.size();
17323 return NULL;
17324 }
17325
17326 return assubscreenscripts[index].c_str();
17327 }
17328
17329 12 static ListData assignffc_list(assignffclist, &font);
17330 12 static ListData assignffcscript_list(assignffcscriptlist, &font);
17331 12 static ListData assignglobal_list(assigngloballist, &font);
17332 12 static ListData assignglobalscript_list(assignglobalscriptlist, &font);
17333 12 static ListData assignitem_list(assignitemlist, &font);
17334 12 static ListData assignitemscript_list(assignitemscriptlist, &font);
17335 12 static ListData assignnpc_list(assignnpclist, &font);
17336 12 static ListData assignnpcscript_list(assignnpcscriptlist, &font);
17337 12 static ListData assignlweapon_list(assignlweaponlist, &font);
17338 12 static ListData assignlweaponscript_list(assignlweaponscriptlist, &font);
17339 12 static ListData assigneweapon_list(assigneweaponlist, &font);
17340 12 static ListData assigneweaponscript_list(assigneweaponscriptlist, &font);
17341
17342 12 static ListData assignplayer_list(assignplayerlist, &font);
17343 12 static ListData assignplayerscript_list(assignplayerscriptlist, &font);
17344
17345 12 static ListData assigndmap_list(assigndmaplist, &font);
17346 12 static ListData assigndmapscript_list(assigndmapscriptlist, &font);
17347
17348 12 static ListData assignscreen_list(assignscreenlist, &font);
17349 12 static ListData assignscreenscript_list(assignscreenscriptlist, &font);
17350
17351 12 static ListData assignitemsprite_list(assignitemspritelist, &font);
17352 12 static ListData assignitemspritescript_list(assignitemspritescriptlist, &font);
17353
17354 12 static ListData assigncombo_list(assigncombolist, &font);
17355 12 static ListData assigncomboscript_list(assigncomboscriptlist, &font);
17356
17357 12 static ListData assigngeneric_list(assigngenericlist, &font);
17358 12 static ListData assigngenericscript_list(assigngenericscriptlist, &font);
17359
17360 12 static ListData assignsubscreen_list(assignsubscreenlist, &font);
17361 12 static ListData assignsubscreenscript_list(assignsubscreenscriptlist, &font);
17362
17363 static DIALOG assignscript_dlg[] =
17364 {
17365 // x y w h fg bg key flags d1 d2 dp
17366 12 { jwin_win_proc, 0, 0, 330, 236, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Assign Compiled Script", NULL, NULL },
17367 12 { jwin_tab_proc, 6, 25, 330-12, 130, 0, 0, 0, 0, 0, 0, assignscript_tabs, NULL, (void*)assignscript_dlg },
17368 12 { jwin_button_proc, 251, 207, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
17369 12 { jwin_button_proc, 182, 207, 61, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
17370 12 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignffc_list, NULL, NULL },
17371 12 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignffcscript_list, NULL, NULL },
17372 //6
17373 12 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
17374 12 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignglobal_list, NULL, NULL },
17375 12 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignglobalscript_list, NULL, NULL },
17376 //9
17377 12 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
17378 12 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignitem_list, NULL, NULL },
17379 12 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignitemscript_list, NULL, NULL },
17380 //12
17381 12 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
17382 //13
17383 12 { jwin_check_proc, 22, 211, 90, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Output ZASM code to allegro.log", NULL, NULL },
17384 12 { jwin_text_proc, 22, 178, 90, 24, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
17385 12 { d_dummy_proc, 0, 0, 0, 0, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
17386 //16
17387 12 { d_dummy_proc, 0, 0, 0, 0, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
17388 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
17389 //npc scripts
17390 12 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignnpc_list, NULL, NULL },
17391 12 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignnpcscript_list, NULL, NULL },
17392 //20
17393 12 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
17394 //21
17395 12 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignlweapon_list, NULL, NULL },
17396 12 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignlweaponscript_list, NULL, NULL },
17397 //23
17398 12 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
17399 //24
17400 12 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assigneweapon_list, NULL, NULL },
17401 12 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assigneweaponscript_list, NULL, NULL },
17402 //26
17403 12 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
17404 //27
17405 12 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignplayer_list, NULL, NULL },
17406 12 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignplayerscript_list, NULL, NULL },
17407 //29
17408 12 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
17409 //30
17410 12 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignscreen_list, NULL, NULL },
17411 12 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignscreenscript_list, NULL, NULL },
17412 //32
17413 12 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
17414 //33
17415 12 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assigndmap_list, NULL, NULL },
17416 12 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assigndmapscript_list, NULL, NULL },
17417 //35
17418 12 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
17419 //36
17420 12 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignitemsprite_list, NULL, NULL },
17421 12 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignitemspritescript_list, NULL, NULL },
17422 //38
17423 12 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
17424
17425 //39
17426 12 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assigncombo_list, NULL, NULL },
17427 12 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assigncomboscript_list, NULL, NULL },
17428 //41
17429 12 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
17430 12 { jwin_button_proc, 78-24, 158, 48, 16, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Script Info", NULL, NULL },
17431 12 { jwin_button_proc, 174+78-24, 158, 48, 16, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Script Info", NULL, NULL },
17432 12 { jwin_button_proc, 87+78-24, 158, 48, 16, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Clear", NULL, NULL },
17433 //45
17434 12 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assigngeneric_list, NULL, NULL },
17435 12 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assigngenericscript_list, NULL, NULL },
17436 //47
17437 12 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
17438 //48
17439 12 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignsubscreen_list, NULL, NULL },
17440 12 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignsubscreenscript_list, NULL, NULL },
17441 //50
17442 12 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
17443 12 { jwin_check_proc, 22, 221, 90, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "...And output ZASM comments", NULL, NULL },
17444
17445 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
17446
17447 };
17448
17449 int32_t txtout(BITMAP* dest, const char* txt, int32_t x, int32_t y, bool disabled)
17450 {
17451 if(disabled)
17452 {
17453 gui_textout_ln(dest, font, (uint8_t*)txt, x+1, y+1, scheme[jcLIGHT], scheme[jcBOX], 0);
17454 return gui_textout_ln(dest, font, (uint8_t*)txt, x, y, scheme[jcMEDDARK], -1, 0);
17455 }
17456 else
17457 {
17458 return gui_textout_ln(dest, font, (uint8_t*)txt, x, y, scheme[jcBOXFG], scheme[jcBOX], 0);
17459 }
17460 }
17461
17462 int32_t jwin_zmeta_proc(int32_t msg, DIALOG *d, int32_t )
17463 {
17464 int32_t ret = D_O_K;
17465 ASSERT(d);
17466
17467 BITMAP* target = (msg==MSG_START ? NULL : screen);
17468 switch(msg)
17469 {
17470 case MSG_START:
17471 case MSG_DRAW:
17472 {
17473 FONT *oldfont = font;
17474
17475 if(d->dp2)
17476 {
17477 font = (FONT*)d->dp2;
17478 }
17479
17480 bool disabled = (d->flags & D_DISABLED) != 0;
17481 if(d->dp)
17482 {
17483 zasm_meta const& meta = *((zasm_meta*)d->dp);
17484 int32_t ind = -1;
17485 d->w = 0;
17486 if(!meta.valid())
17487 {
17488 d->w = txtout(target, "Invalid ZASM metadata found!", d->x, d->y, disabled);
17489 ++ind;
17490 }
17491
17492 int32_t t_w = 0;
17493 char buf[1024];
17494 memset(buf, 0, sizeof(buf));
17495 sprintf(buf, "ZASM Version: %d", meta.zasm_v);
17496 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
17497 d->w = zc_max(d->w, t_w);
17498 memset(buf, 0, sizeof(buf));
17499 sprintf(buf, "Metadata Version: %d", meta.meta_v);
17500 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
17501 d->w = zc_max(d->w, t_w);
17502 memset(buf, 0, sizeof(buf));
17503 sprintf(buf, "FFScript Version: %d", meta.ffscript_v);
17504 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
17505 d->w = zc_max(d->w, t_w);
17506 memset(buf, 0, sizeof(buf));
17507 sprintf(buf, "Script Name: %s", meta.script_name.c_str());
17508 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
17509 d->w = zc_max(d->w, t_w);
17510 memset(buf, 0, sizeof(buf));
17511 sprintf(buf, "Author: %s", meta.author.c_str());
17512 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
17513 d->w = zc_max(d->w, t_w);
17514 memset(buf, 0, sizeof(buf));
17515 sprintf(buf, "Script Type: %s", get_script_name(meta.script_type).c_str());
17516 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
17517 d->w = zc_max(d->w, t_w);
17518 for(auto q = 0; q < 4; ++q)
17519 {
17520 if(!meta.attributes[q].size())
17521 continue;
17522 memset(buf, 0, sizeof(buf));
17523 sprintf(buf, "Attributes[%d]: %s", q, meta.attributes[q].c_str());
17524 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
17525 d->w = zc_max(d->w, t_w);
17526 }
17527 for(auto q = 0; q < 8; ++q)
17528 {
17529 if(!meta.attribytes[q].size())
17530 continue;
17531 memset(buf, 0, sizeof(buf));
17532 sprintf(buf, "Attribytes[%d]: %s", q, meta.attribytes[q].c_str());
17533 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
17534 d->w = zc_max(d->w, t_w);
17535 }
17536 for(auto q = 0; q < 8; ++q)
17537 {
17538 if(!meta.attrishorts[q].size())
17539 continue;
17540 memset(buf, 0, sizeof(buf));
17541 sprintf(buf, "Attrishorts[%d]: %s", q, meta.attrishorts[q].c_str());
17542 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
17543 d->w = zc_max(d->w, t_w);
17544 }
17545 bool indentrun = false;
17546 int32_t run_indent = txtout(NULL, "void run(", 0, 0, false);
17547 std::ostringstream oss;
17548 oss << "void run(";
17549 for(int32_t q = 0; q < 8; ++q)
17550 {
17551 if(!meta.run_idens[q].size() || meta.run_types[q] == ZMETA_NULL_TYPE) continue;
17552 if(q > 0)
17553 oss << ", ";
17554 string type_name = ZScript::getDataTypeName(meta.run_types[q]);
17555 lowerstr(type_name); //all lowercase for this output
17556 if(oss.str().size() > unsigned(indentrun ? 41 : 50))
17557 {
17558 memset(buf, 0, sizeof(buf));
17559 sprintf(buf, "%s", oss.str().c_str());
17560 t_w = txtout(target, buf, d->x + (indentrun ? run_indent : 0), d->y + ((++ind)*(text_height(font) + 3)), disabled) + (indentrun ? run_indent : 0);
17561 d->w = zc_max(d->w, t_w);
17562 oss.str("");
17563 indentrun = true;
17564 }
17565 oss << type_name.c_str() << " " << meta.run_idens[q];
17566 }
17567 oss << ");";
17568 memset(buf, 0, sizeof(buf));
17569 sprintf(buf, "%s", oss.str().c_str());
17570 t_w = txtout(target, buf, d->x + (indentrun ? run_indent : 0), d->y + ((++ind)*(text_height(font) + 3)), disabled) + (indentrun ? run_indent : 0);
17571 d->w = zc_max(d->w, t_w);
17572 memset(buf, 0, sizeof(buf));
17573 sprintf(buf, "Compiler Version: %d.%d.%d.%d", meta.compiler_v1, meta.compiler_v2, meta.compiler_v3, meta.compiler_v4);
17574 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
17575 d->w = zc_max(d->w, t_w);
17576 memset(buf, 0, sizeof(buf));
17577 sprintf(buf, "Parser-generated: %s", (meta.flags & ZMETA_AUTOGEN)!=0 ? "TRUE" : "FALSE");
17578 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
17579 d->w = zc_max(d->w, t_w);
17580 d->h = (++ind) * (text_height(font) + 3) -3;
17581 }
17582 else
17583 {
17584 d->w = txtout(target, "No ZASM metadata found!", d->x, d->y, disabled);
17585 d->h = text_height(font);
17586 }
17587
17588 if(d->dp3) //function trigger
17589 {
17590 typedef void (*funcType)(void);
17591 funcType func=reinterpret_cast<funcType>(d->dp3);
17592 func();
17593 }
17594
17595 font = oldfont;
17596 break;
17597 }
17598 }
17599
17600 return ret;
17601 }
17602
17603 void resize_scriptinfo_dlg();
17604
17605 static DIALOG scriptinfo_dlg[] =
17606 {
17607 // x y w h fg bg key flags d1 d2 dp
17608 { jwin_win_proc, 0, 0, 200, 150, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Script Metadata", NULL, NULL },
17609 { d_dummy_proc, 6, 25, 330-12, 130, 0, 0, 0, 0, 0, 0, assignscript_tabs, NULL, NULL },
17610 { jwin_button_proc, 70, 120, 60, 20, vc(14), vc(1), 'k', D_EXIT, 0, 0, (void *) "Done", NULL, NULL },
17611 { jwin_zmeta_proc, 50, 30, 100, 100, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, (void*)resize_scriptinfo_dlg },
17612
17613 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
17614 };
17615
17616 void resize_scriptinfo_dlg()
17617 {
17618 DIALOG *meta_proc = &scriptinfo_dlg[3], *window = &scriptinfo_dlg[0], *ok_button = &scriptinfo_dlg[2];
17619 int32_t bmargin = 15, hmargins = 30;
17620 jwin_ulalign_dialog(scriptinfo_dlg);
17621 window->w = hmargins*2 + meta_proc->w;
17622 meta_proc->x = hmargins;
17623 window->h = meta_proc->y + meta_proc->h + ok_button->h + bmargin*2;
17624 ok_button->x = (window->w/2)-(ok_button->w/2);
17625 ok_button->y = meta_proc->y + meta_proc->h + bmargin;
17626 jwin_center_dialog(scriptinfo_dlg);
17627 }
17628
17629 void showScriptInfo(zasm_meta const* meta)
17630 {
17631 scriptinfo_dlg[3].dp = (void*)meta;
17632 scriptinfo_dlg[0].dp2 = get_zc_font(font_lfont);
17633 large_dialog(scriptinfo_dlg);
17634 jwin_zmeta_proc(MSG_START,&scriptinfo_dlg[3],0); //Calculate size before calling dialog
17635 jwin_center_dialog(scriptinfo_dlg);
17636 do_zqdialog(scriptinfo_dlg,2);
17637 }
17638
17639 void write_includepaths();
17640 void call_compile_settings();
17641 int32_t onZScriptCompilerSettings()
17642 {
17643 call_compile_settings();
17644 return D_O_K;
17645 }
17646
17647 void doEditZScript()
17648 {
17649 if(do_box_edit(zScript, "ZScript Buffer", false, false))
17650 mark_save_dirty();
17651 }
17652
17653 std::string qst_cfg_header_from_path(std::string path);
17654 extern char *filepath;
17655 string get_box_cfg_hdr(int num)
17656 {
17657 if(num)
17658 return "misc";
17659 return qst_cfg_header_from_path(filepath);
17660 }
17661
17662 6 void clear_map_states()
17663 {
17664
2/2
✓ Branch 0 taken 3066 times.
✓ Branch 1 taken 6 times.
3072 for(map<int32_t, script_slot_data>::iterator it = ffcmap.begin();
17665 3072 it != ffcmap.end(); ++it)
17666 {
17667 3066 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
17668 3066 }
17669
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 6 times.
54 for(map<int32_t, script_slot_data>::iterator it = globalmap.begin();
17670 54 it != globalmap.end(); ++it)
17671 {
17672 48 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
17673 48 }
17674
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(map<int32_t, script_slot_data>::iterator it = itemmap.begin();
17675 1536 it != itemmap.end(); ++it)
17676 {
17677 1530 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
17678 1530 }
17679
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(map<int32_t, script_slot_data>::iterator it = npcmap.begin();
17680 1536 it != npcmap.end(); ++it)
17681 {
17682 1530 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
17683 1530 }
17684
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(map<int32_t, script_slot_data>::iterator it = ewpnmap.begin();
17685 1536 it != ewpnmap.end(); ++it)
17686 {
17687 1530 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
17688 1530 }
17689
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(map<int32_t, script_slot_data>::iterator it = lwpnmap.begin();
17690 1536 it != lwpnmap.end(); ++it)
17691 {
17692 1530 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
17693 1530 }
17694
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 6 times.
30 for(map<int32_t, script_slot_data>::iterator it = playermap.begin();
17695 30 it != playermap.end(); ++it)
17696 {
17697 24 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
17698 24 }
17699
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(map<int32_t, script_slot_data>::iterator it = dmapmap.begin();
17700 1536 it != dmapmap.end(); ++it)
17701 {
17702 1530 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
17703 1530 }
17704
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(map<int32_t, script_slot_data>::iterator it = screenmap.begin();
17705 1536 it != screenmap.end(); ++it)
17706 {
17707 1530 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
17708 1530 }
17709
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(map<int32_t, script_slot_data>::iterator it = itemspritemap.begin();
17710 1536 it != itemspritemap.end(); ++it)
17711 {
17712 1530 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
17713 1530 }
17714
2/2
✓ Branch 0 taken 3066 times.
✓ Branch 1 taken 6 times.
3072 for(map<int32_t, script_slot_data>::iterator it = comboscriptmap.begin();
17715 3072 it != comboscriptmap.end(); ++it)
17716 {
17717 3066 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
17718 3066 }
17719 6 }
17720
17721 void clearAssignSlotDlg()
17722 {
17723 assignscript_dlg[0].dp2 = get_zc_font(font_lfont);
17724 assignscript_dlg[4].d1 = -1;
17725 assignscript_dlg[5].d1 = -1;
17726 assignscript_dlg[7].d1 = -1;
17727 assignscript_dlg[8].d1 = -1;
17728 assignscript_dlg[10].d1 = -1;
17729 assignscript_dlg[11].d1 = -1;
17730 assignscript_dlg[13].flags = 0;
17731 }
17732
17733 void inc_script_name(string& name)
17734 {
17735 size_t pos = name.find_last_not_of("0123456789");
17736 pos = name.find_first_of("0123456789",pos);
17737 std::ostringstream oss;
17738 if(pos == string::npos)
17739 {
17740 oss << name << 2;
17741 }
17742 else
17743 {
17744 int32_t val = atoi(name.substr(pos).c_str());
17745 oss << name.substr(0,pos) << val+1;
17746 }
17747 name = oss.str();
17748 }
17749
17750 enum script_slot_type
17751 {
17752 type_ffc, type_global, type_itemdata, type_npc, type_lweapon, type_eweapon,
17753 type_hero, type_dmap, type_screen, type_itemsprite, type_combo, type_generic,
17754 type_subscreen, num_types
17755 };
17756 script_slot_type getType(ScriptType type)
17757 {
17758 switch(type)
17759 {
17760 case ScriptType::FFC: return type_ffc;
17761 case ScriptType::Global: return type_global;
17762 case ScriptType::Item: return type_itemdata;
17763 case ScriptType::NPC: return type_npc;
17764 case ScriptType::Lwpn: return type_lweapon;
17765 case ScriptType::Ewpn: return type_eweapon;
17766 case ScriptType::Hero: return type_hero;
17767 case ScriptType::DMap:
17768 case ScriptType::ScriptedActiveSubscreen:
17769 case ScriptType::ScriptedPassiveSubscreen:
17770 case ScriptType::OnMap:
17771 return type_dmap;
17772 case ScriptType::Generic: case ScriptType::GenericFrozen:
17773 return type_generic;
17774 case ScriptType::Screen: return type_screen;
17775 case ScriptType::ItemSprite: return type_itemsprite;
17776 case ScriptType::Combo: return type_combo;
17777 case ScriptType::EngineSubscreen: return type_subscreen;
17778 default: return type_ffc; //Default
17779 }
17780 }
17781 #define SLOTMSGFLAG_MISSING 0x01
17782 #define SLOTMSG_SIZE 512
17783 bool checkSkip(int32_t format, byte flags)
17784 {
17785 switch(format)
17786 {
17787 case SCRIPT_FORMAT_DEFAULT:
17788 return (flags != 0);
17789 case SCRIPT_FORMAT_INVALID:
17790 return ((flags & SLOTMSGFLAG_MISSING)==0);
17791 default: return true;
17792 }
17793 }
17794 void clearAllSlots(int32_t type, byte flags = 0)
17795 {
17796 bound(type,0,num_types-1);
17797 switch(type)
17798 {
17799 case type_ffc:
17800 {
17801 for(int32_t q = 0; q < NUMSCRIPTFFC-1; ++q)
17802 {
17803 if(checkSkip(ffcmap[q].format, flags)) continue;
17804 ffcmap[q].scriptname = "";
17805 ffcmap[q].format = SCRIPT_FORMAT_DEFAULT;
17806 }
17807 break;
17808 }
17809 case type_global:
17810 {
17811 //Start at 1 to not clear Init
17812 for(int32_t q = 1; q < NUMSCRIPTGLOBAL; ++q)
17813 {
17814 if(checkSkip(globalmap[q].format, flags)) continue;
17815 globalmap[q].scriptname = "";
17816 globalmap[q].format = SCRIPT_FORMAT_DEFAULT;
17817 }
17818 break;
17819 }
17820 case type_itemdata:
17821 {
17822 for(int32_t q = 0; q < NUMSCRIPTITEM-1; ++q)
17823 {
17824 if(checkSkip(itemmap[q].format, flags)) continue;
17825 itemmap[q].scriptname = "";
17826 itemmap[q].format = SCRIPT_FORMAT_DEFAULT;
17827 }
17828 break;
17829 }
17830 case type_npc:
17831 {
17832 for(int32_t q = 0; q < NUMSCRIPTGUYS-1; ++q)
17833 {
17834 if(checkSkip(npcmap[q].format, flags)) continue;
17835 npcmap[q].scriptname = "";
17836 npcmap[q].format = SCRIPT_FORMAT_DEFAULT;
17837 }
17838 break;
17839 }
17840 case type_lweapon:
17841 {
17842 for(int32_t q = 0; q < NUMSCRIPTWEAPONS-1; ++q)
17843 {
17844 if(checkSkip(lwpnmap[q].format, flags)) continue;
17845 lwpnmap[q].scriptname = "";
17846 lwpnmap[q].format = SCRIPT_FORMAT_DEFAULT;
17847 }
17848 break;
17849 }
17850 case type_eweapon:
17851 {
17852 for(int32_t q = 0; q < NUMSCRIPTWEAPONS-1; ++q)
17853 {
17854 if(checkSkip(ewpnmap[q].format, flags)) continue;
17855 ewpnmap[q].scriptname = "";
17856 ewpnmap[q].format = SCRIPT_FORMAT_DEFAULT;
17857 }
17858 break;
17859 }
17860 case type_hero:
17861 {
17862 for(int32_t q = 0; q < NUMSCRIPTHERO-1; ++q)
17863 {
17864 if(checkSkip(playermap[q].format, flags)) continue;
17865 playermap[q].scriptname = "";
17866 playermap[q].format = SCRIPT_FORMAT_DEFAULT;
17867 }
17868 break;
17869 }
17870 case type_dmap:
17871 {
17872 for(int32_t q = 0; q < NUMSCRIPTSDMAP-1; ++q)
17873 {
17874 if(checkSkip(dmapmap[q].format, flags)) continue;
17875 dmapmap[q].scriptname = "";
17876 dmapmap[q].format = SCRIPT_FORMAT_DEFAULT;
17877 }
17878 break;
17879 }
17880 case type_screen:
17881 {
17882 for(int32_t q = 0; q < NUMSCRIPTSCREEN-1; ++q)
17883 {
17884 if(checkSkip(screenmap[q].format, flags)) continue;
17885 screenmap[q].scriptname = "";
17886 screenmap[q].format = SCRIPT_FORMAT_DEFAULT;
17887 }
17888 break;
17889 }
17890 case type_itemsprite:
17891 {
17892 for(int32_t q = 0; q < NUMSCRIPTSITEMSPRITE-1; ++q)
17893 {
17894 if(checkSkip(itemspritemap[q].format, flags)) continue;
17895 itemspritemap[q].scriptname = "";
17896 itemspritemap[q].format = SCRIPT_FORMAT_DEFAULT;
17897 }
17898 break;
17899 }
17900 case type_combo:
17901 {
17902 for(int32_t q = 0; q < NUMSCRIPTSCOMBODATA-1; ++q)
17903 {
17904 if(checkSkip(comboscriptmap[q].format, flags)) continue;
17905 comboscriptmap[q].scriptname = "";
17906 comboscriptmap[q].format = SCRIPT_FORMAT_DEFAULT;
17907 }
17908 break;
17909 }
17910 case type_generic:
17911 {
17912 for(int32_t q = 0; q < NUMSCRIPTSGENERIC-1; ++q)
17913 {
17914 if(checkSkip(genericmap[q].format, flags)) continue;
17915 genericmap[q].scriptname = "";
17916 genericmap[q].format = SCRIPT_FORMAT_DEFAULT;
17917 }
17918 break;
17919 }
17920 case type_subscreen:
17921 {
17922 for(int32_t q = 0; q < NUMSCRIPTSSUBSCREEN-1; ++q)
17923 {
17924 if(checkSkip(subscreenmap[q].format, flags)) continue;
17925 subscreenmap[q].scriptname = "";
17926 subscreenmap[q].format = SCRIPT_FORMAT_DEFAULT;
17927 }
17928 break;
17929 }
17930 }
17931 }
17932
17933 static bool doslots_log_output = false, doslots_comment_output = true;
17934 6 void setup_scriptslot_dlg(char* buf, byte flags)
17935 {
17936 //{ Set up the textbox at the bottom, and auto-resize height based on it
17937 6 int32_t prev_height = assignscript_dlg[14].h;
17938 6 memset(buf, 0, SLOTMSG_SIZE);
17939 //
17940 6 strcpy(buf, "Slots with matching names have been updated.\n");
17941
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 if(flags & SLOTMSGFLAG_MISSING)
17942 3 strcat(buf,"Scripts prefixed with '--' were not found, and will not function.\n");
17943 6 strcat(buf,"Global scripts named 'Init' will be appended to '~Init'");
17944 //
17945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 SETFLAG(assignscript_dlg[13].flags, D_SELECTED, doslots_log_output);
17946
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 SETFLAG(assignscript_dlg[51].flags, D_SELECTED, doslots_comment_output);
17947 6 assignscript_dlg[14].dp = buf;
17948 6 object_message(&assignscript_dlg[14], MSG_START, 0); //Set the width/height
17949
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(int32_t diff = assignscript_dlg[14].h - prev_height) //resize dlg
17950 {
17951 6 int32_t prev_bottom = assignscript_dlg[14].y + prev_height;
17952
2/2
✓ Branch 0 taken 306 times.
✓ Branch 1 taken 6 times.
312 for(int32_t q = 1; assignscript_dlg[q].proc; ++q)
17953 {
17954
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 300 times.
306 if(q==14) continue; //Don't change self
17955
2/2
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 24 times.
300 if(assignscript_dlg[q].y < prev_bottom) continue; //above proc
17956 24 assignscript_dlg[q].y += diff;
17957 24 }
17958 6 assignscript_dlg[0].h += diff;
17959 6 jwin_center_dialog(assignscript_dlg);
17960 6 }
17961 //}
17962 6 }
17963
17964 std::string global_slotnames[NUMSCRIPTGLOBAL] = {
17965 "Init",
17966 "Active",
17967 "onExit",
17968 "onSaveLoad",
17969 "onLaunch",
17970 "onContGame",
17971 "onF6Menu",
17972 "onSave",
17973 };
17974 std::string player_slotnames[NUMSCRIPTHERO-1] = {
17975 "Init",
17976 "Active",
17977 "onDeath",
17978 "onWin",
17979 };
17980 6 byte reload_scripts(map<string, disassembled_script_data> &scripts)
17981 {
17982 6 byte slotflags = 0;
17983 char temp[100];
17984
2/2
✓ Branch 0 taken 3066 times.
✓ Branch 1 taken 6 times.
3072 for(int32_t i = 0; i < NUMSCRIPTFFC-1; i++)
17985 {
17986
2/2
✓ Branch 0 taken 2987 times.
✓ Branch 1 taken 79 times.
3066 if(ffcmap[i].isEmpty())
17987 2987 sprintf(temp, "Slot %d:", i+1);
17988 else
17989 {
17990 79 sprintf(temp, "Slot %d:", i+1);
17991
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 6 times.
79 if(scripts.find(ffcmap[i].scriptname) != scripts.end())
17992 73 ffcmap[i].format = SCRIPT_FORMAT_DEFAULT;
17993 else // Previously loaded script not found
17994 {
17995 6 ffcmap[i].format = SCRIPT_FORMAT_INVALID;
17996 6 slotflags |= SLOTMSGFLAG_MISSING;
17997 }
17998 }
17999 3066 ffcmap[i].slotname = temp;
18000 3066 ffcmap[i].update();
18001 3066 }
18002
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 6 times.
54 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; i++)
18003 {
18004
1/2
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
48 globalmap[i].slotname=fmt::format("{}:",global_slotnames[i]);
18005
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 11 times.
48 if(!globalmap[i].isEmpty())
18006 {
18007
2/4
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
11 if(scripts.find(globalmap[i].scriptname) != scripts.end() || globalmap[i].scriptname == "~Init")
18008 11 globalmap[i].format = SCRIPT_FORMAT_DEFAULT;
18009 else // Unloaded
18010 {
18011 globalmap[i].format = SCRIPT_FORMAT_INVALID;
18012 slotflags |= SLOTMSGFLAG_MISSING;
18013 }
18014 11 }
18015 48 globalmap[i].update();
18016 48 }
18017
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(int32_t i = 0; i < NUMSCRIPTITEM-1; i++)
18018 {
18019
2/2
✓ Branch 0 taken 1517 times.
✓ Branch 1 taken 13 times.
1530 if(itemmap[i].isEmpty())
18020 1517 sprintf(temp, "Slot %d:", i+1);
18021 else
18022 {
18023 13 sprintf(temp, "Slot %d:", i+1);
18024
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(scripts.find(itemmap[i].scriptname) != scripts.end())
18025 13 itemmap[i].format = SCRIPT_FORMAT_DEFAULT;
18026 else // Previously loaded script not found
18027 {
18028 itemmap[i].format = SCRIPT_FORMAT_INVALID;
18029 slotflags |= SLOTMSGFLAG_MISSING;
18030 }
18031 }
18032 1530 itemmap[i].slotname = temp;
18033 1530 itemmap[i].update();
18034 1530 }
18035
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(int32_t i = 0; i < NUMSCRIPTGUYS-1; i++)
18036 {
18037
1/2
✓ Branch 0 taken 1530 times.
✗ Branch 1 not taken.
1530 if(npcmap[i].isEmpty())
18038 1530 sprintf(temp, "Slot %d:", i+1);
18039 else
18040 {
18041 sprintf(temp, "Slot %d:", i+1);
18042 if(scripts.find(npcmap[i].scriptname) != scripts.end())
18043 npcmap[i].format = SCRIPT_FORMAT_DEFAULT;
18044 else // Previously loaded script not found
18045 {
18046 npcmap[i].format = SCRIPT_FORMAT_INVALID;
18047 slotflags |= SLOTMSGFLAG_MISSING;
18048 }
18049 }
18050 1530 npcmap[i].slotname = temp;
18051 1530 npcmap[i].update();
18052 1530 }
18053
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(int32_t i = 0; i < NUMSCRIPTWEAPONS-1; i++)
18054 {
18055
1/2
✓ Branch 0 taken 1530 times.
✗ Branch 1 not taken.
1530 if(ewpnmap[i].isEmpty())
18056 1530 sprintf(temp, "Slot %d:", i+1);
18057 else
18058 {
18059 sprintf(temp, "Slot %d:", i+1);
18060 if(scripts.find(ewpnmap[i].scriptname) != scripts.end())
18061 ewpnmap[i].format = SCRIPT_FORMAT_DEFAULT;
18062 else // Previously loaded script not found
18063 {
18064 ewpnmap[i].format = SCRIPT_FORMAT_INVALID;
18065 slotflags |= SLOTMSGFLAG_MISSING;
18066 }
18067 }
18068 1530 ewpnmap[i].slotname = temp;
18069 1530 ewpnmap[i].update();
18070 1530 }
18071
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(int32_t i = 0; i < NUMSCRIPTWEAPONS-1; i++)
18072 {
18073
2/2
✓ Branch 0 taken 1529 times.
✓ Branch 1 taken 1 times.
1530 if(lwpnmap[i].isEmpty())
18074 1529 sprintf(temp, "Slot %d:", i+1);
18075 else
18076 {
18077 1 sprintf(temp, "Slot %d:", i+1);
18078
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(scripts.find(lwpnmap[i].scriptname) != scripts.end())
18079 1 lwpnmap[i].format = SCRIPT_FORMAT_DEFAULT;
18080 else // Previously loaded script not found
18081 {
18082 lwpnmap[i].format = SCRIPT_FORMAT_INVALID;
18083 slotflags |= SLOTMSGFLAG_MISSING;
18084 }
18085 }
18086 1530 lwpnmap[i].slotname = temp;
18087 1530 lwpnmap[i].update();
18088 1530 }
18089
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 6 times.
30 for(int32_t i = 0; i < NUMSCRIPTHERO-1; i++)
18090 {
18091
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 playermap[i].slotname=fmt::format("{}:",player_slotnames[i]);
18092
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!playermap[i].isEmpty())
18093 {
18094 if(scripts.find(playermap[i].scriptname) != scripts.end())
18095 playermap[i].format = SCRIPT_FORMAT_DEFAULT;
18096 else // Unloaded
18097 {
18098 playermap[i].format = SCRIPT_FORMAT_INVALID;
18099 slotflags |= SLOTMSGFLAG_MISSING;
18100 }
18101 }
18102 24 playermap[i].update();
18103 24 }
18104
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(int32_t i = 0; i < NUMSCRIPTSCREEN-1; i++)
18105 {
18106
2/2
✓ Branch 0 taken 1528 times.
✓ Branch 1 taken 2 times.
1530 if(screenmap[i].isEmpty())
18107 1528 sprintf(temp, "Slot %d:", i+1);
18108 else
18109 {
18110 2 sprintf(temp, "Slot %d:", i+1);
18111
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(scripts.find(screenmap[i].scriptname) != scripts.end())
18112 2 screenmap[i].format = SCRIPT_FORMAT_DEFAULT;
18113 else // Previously loaded script not found
18114 {
18115 screenmap[i].format = SCRIPT_FORMAT_INVALID;
18116 slotflags |= SLOTMSGFLAG_MISSING;
18117 }
18118 }
18119 1530 screenmap[i].slotname = temp;
18120 1530 screenmap[i].update();
18121 1530 }
18122
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(int32_t i = 0; i < NUMSCRIPTSDMAP-1; i++)
18123 {
18124
2/2
✓ Branch 0 taken 1525 times.
✓ Branch 1 taken 5 times.
1530 if(dmapmap[i].isEmpty())
18125 1525 sprintf(temp, "Slot %d:", i+1);
18126 else
18127 {
18128 5 sprintf(temp, "Slot %d:", i+1);
18129
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(scripts.find(dmapmap[i].scriptname) != scripts.end())
18130 5 dmapmap[i].format = SCRIPT_FORMAT_DEFAULT;
18131 else // Previously loaded script not found
18132 {
18133 dmapmap[i].format = SCRIPT_FORMAT_INVALID;
18134 slotflags |= SLOTMSGFLAG_MISSING;
18135 }
18136 }
18137 1530 dmapmap[i].slotname = temp;
18138 1530 dmapmap[i].update();
18139 1530 }
18140
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE-1; i++)
18141 {
18142
1/2
✓ Branch 0 taken 1530 times.
✗ Branch 1 not taken.
1530 if(itemspritemap[i].isEmpty())
18143 1530 sprintf(temp, "Slot %d:", i+1);
18144 else
18145 {
18146 sprintf(temp, "Slot %d:", i+1);
18147 if(scripts.find(itemspritemap[i].scriptname) != scripts.end())
18148 itemspritemap[i].format = SCRIPT_FORMAT_DEFAULT;
18149 else // Previously loaded script not found
18150 {
18151 itemspritemap[i].format = SCRIPT_FORMAT_INVALID;
18152 slotflags |= SLOTMSGFLAG_MISSING;
18153 }
18154 }
18155 1530 itemspritemap[i].slotname = temp;
18156 1530 itemspritemap[i].update();
18157 1530 }
18158
2/2
✓ Branch 0 taken 3066 times.
✓ Branch 1 taken 6 times.
3072 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA-1; i++)
18159 {
18160
1/2
✓ Branch 0 taken 3066 times.
✗ Branch 1 not taken.
3066 if(comboscriptmap[i].isEmpty())
18161 3066 sprintf(temp, "Slot %d:", i+1);
18162 else
18163 {
18164 sprintf(temp, "Slot %d:", i+1);
18165 if(scripts.find(comboscriptmap[i].scriptname) != scripts.end())
18166 comboscriptmap[i].format = SCRIPT_FORMAT_DEFAULT;
18167 else // Previously loaded script not found
18168 {
18169 comboscriptmap[i].format = SCRIPT_FORMAT_INVALID;
18170 slotflags |= SLOTMSGFLAG_MISSING;
18171 }
18172 }
18173 3066 comboscriptmap[i].slotname = temp;
18174 3066 comboscriptmap[i].update();
18175 3066 }
18176
2/2
✓ Branch 0 taken 3066 times.
✓ Branch 1 taken 6 times.
3072 for(int32_t i = 0; i < NUMSCRIPTSGENERIC-1; i++)
18177 {
18178
2/2
✓ Branch 0 taken 3045 times.
✓ Branch 1 taken 21 times.
3066 if(genericmap[i].isEmpty())
18179 3045 sprintf(temp, "Slot %d:", i+1);
18180 else
18181 {
18182 21 sprintf(temp, "Slot %d:", i+1);
18183
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 1 times.
21 if(scripts.find(genericmap[i].scriptname) != scripts.end())
18184 20 genericmap[i].format = SCRIPT_FORMAT_DEFAULT;
18185 else // Previously loaded script not found
18186 {
18187 1 genericmap[i].format = SCRIPT_FORMAT_INVALID;
18188 1 slotflags |= SLOTMSGFLAG_MISSING;
18189 }
18190 }
18191 3066 genericmap[i].slotname = temp;
18192 3066 genericmap[i].update();
18193 3066 }
18194
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(int32_t i = 0; i < NUMSCRIPTSSUBSCREEN-1; i++)
18195 {
18196
1/2
✓ Branch 0 taken 1530 times.
✗ Branch 1 not taken.
1530 if(subscreenmap[i].isEmpty())
18197 1530 sprintf(temp, "Slot %d:", i+1);
18198 else
18199 {
18200 sprintf(temp, "Slot %d:", i+1);
18201 if(scripts.find(subscreenmap[i].scriptname) != scripts.end())
18202 subscreenmap[i].format = SCRIPT_FORMAT_DEFAULT;
18203 else // Previously loaded script not found
18204 {
18205 subscreenmap[i].format = SCRIPT_FORMAT_INVALID;
18206 slotflags |= SLOTMSGFLAG_MISSING;
18207 }
18208 }
18209 1530 subscreenmap[i].slotname = temp;
18210 1530 subscreenmap[i].update();
18211 1530 }
18212 6 return slotflags;
18213 }
18214
18215 void doClearSlots(byte* flags);
18216
18217 static map<string, disassembled_script_data> *doslot_scripts = nullptr;
18218 21510 bool handle_slot(script_slot_data& slotdata, script_data* scriptdata)
18219 {
18220
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 21385 times.
21510 if(slotdata.hasScriptData())
18221 {
18222 125 auto& data = (*doslot_scripts)[slotdata.scriptname];
18223 125 scriptdata->meta = data.meta;
18224 125 scriptdata->pc = data.pc;
18225 125 scriptdata->end_pc = data.end_pc;
18226 125 scriptdata->zasm_script = zasm_scripts[0];
18227 125 }
18228
1/2
✓ Branch 0 taken 21385 times.
✗ Branch 1 not taken.
21385 else if(scriptdata)
18229 {
18230 21385 scriptdata->zasm_script = nullptr;
18231 21385 scriptdata->meta.zero();
18232 21385 scriptdata->pc = 0;
18233 21385 scriptdata->end_pc = 0;
18234 21385 }
18235 21510 return true;
18236 }
18237 78 bool handle_slot_map(map<int32_t, script_slot_data>& mp, int offs, script_data** scriptdata)
18238 {
18239
2/2
✓ Branch 0 taken 21510 times.
✓ Branch 1 taken 78 times.
21588 for(auto it = mp.begin(); it != mp.end(); it++)
18240 {
18241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21510 times.
21510 if(!handle_slot(it->second, scriptdata[it->first + offs]))
18242 return false;
18243 21510 }
18244 78 return true;
18245 78 }
18246
18247 void smart_slot_named(map<string, disassembled_script_data> &scripts,
18248 vector<string> const& scriptnames, map<int32_t, script_slot_data>& mp,
18249 std::string* slotnames, int slotstart, int slotend)
18250 {
18251 for(int q = slotstart; q < slotend; ++q)
18252 {
18253 auto& lval = mp[q];
18254 if(!lval.isEmpty())
18255 continue; //occupied, leave alone
18256 bool done = false;
18257 if(!done) //Check case-sensitive
18258 for(size_t rind = 0; rind < scriptnames.size(); ++rind)
18259 {
18260 auto const& rval = scriptnames[rind];
18261 if(rval == "<none>") continue;
18262 if(rval == slotnames[q])
18263 { //Perfect match
18264 lval.updateName(rval);
18265 lval.format = scripts[lval.scriptname].format;
18266 done = true;
18267 break;
18268 }
18269 }
18270 if(!done) //Check case-insensitive
18271 for(size_t rind = 0; rind < scriptnames.size(); ++rind)
18272 {
18273 auto const& rval = scriptnames[rind];
18274 if(rval == "<none>") continue;
18275 string lc_rv = rval, lc_slot = slotnames[q];
18276 lowerstr(lc_rv);
18277 lowerstr(lc_slot);
18278 if(lc_rv == lc_slot)
18279 { //Insensitive match
18280 lval.updateName(rval);
18281 lval.format = scripts[lval.scriptname].format;
18282 break;
18283 }
18284 }
18285 }
18286 }
18287 void smart_slot_type(map<string, disassembled_script_data> &scripts,
18288 vector<string> const& scriptnames, map<int32_t, script_slot_data>& mp,
18289 int slotcount)
18290 {
18291 for(size_t rind = 0; rind < scriptnames.size(); ++rind)
18292 {
18293 auto const& rval = scriptnames[rind];
18294 if(rval == "<none>") continue;
18295 script_slot_data* first_open_slot = nullptr;
18296 bool done = false;
18297 for(int q = 0; q < slotcount; ++q)
18298 {
18299 auto& lval = mp[q];
18300 if(lval.isEmpty())
18301 {
18302 if(!first_open_slot)
18303 first_open_slot = &lval;
18304 }
18305 else if(lval.scriptname == rval)
18306 {
18307 done = true;
18308 break;
18309 }
18310 }
18311 if(!done)
18312 {
18313 if(!first_open_slot)
18314 break; //no slots left to assign to!
18315 first_open_slot->updateName(rval);
18316 first_open_slot->format = scripts[first_open_slot->scriptname].format;
18317 }
18318 }
18319 }
18320
18321 6 bool do_slots(vector<shared_ptr<ZScript::Opcode>> const& zasm,
18322 map<string, disassembled_script_data> &scripts, int assign_mode)
18323 {
18324 6 large_dialog(assignscript_dlg);
18325 6 int32_t ret = 3;
18326 6 char slots_msg[SLOTMSG_SIZE] = {0};
18327 6 byte slotflags = reload_scripts(scripts);
18328 6 setup_scriptslot_dlg(slots_msg, slotflags);
18329 6 bool retval = false;
18330
18331 6 popup_zqdialog_start();
18332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 while(!assign_mode)
18333 {
18334 slotflags = reload_scripts(scripts);
18335 ret = do_zqdialog(assignscript_dlg, ret);
18336
18337 switch(ret)
18338 {
18339 case 0:
18340 case 2:
18341 //Cancel
18342 goto exit_do_slots;
18343
18344 case 3: goto auto_do_slots;
18345
18346 case 6:
18347 //<<, FFC
18348 {
18349 int32_t lind = assignscript_dlg[4].d1;
18350 int32_t rind = assignscript_dlg[5].d1;
18351
18352 if(lind < 0 || rind < 0)
18353 break;
18354
18355 if(asffcscripts[rind] == "<none>")
18356 {
18357 ffcmap[lind].scriptname = "";
18358 ffcmap[lind].format = SCRIPT_FORMAT_DEFAULT;
18359 }
18360 else
18361 {
18362 ffcmap[lind].updateName(asffcscripts[rind]);
18363 ffcmap[lind].format = scripts[ffcmap[lind].scriptname].format;
18364 }
18365
18366 break;
18367 }
18368 case 9:
18369 //<<, Global
18370 {
18371 int32_t lind = assignscript_dlg[7].d1;
18372 int32_t rind = assignscript_dlg[8].d1;
18373
18374 if(lind < 0 || rind < 0)
18375 break;
18376
18377 if(lind == 0)
18378 {
18379 jwin_alert("Error","ZScript reserves this slot.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
18380 break;
18381 }
18382
18383 if(asglobalscripts[rind] == "<none>")
18384 {
18385 globalmap[lind].scriptname = "";
18386 globalmap[lind].format = SCRIPT_FORMAT_DEFAULT;
18387 }
18388 else
18389 {
18390 globalmap[lind].updateName(asglobalscripts[rind]);
18391 globalmap[lind].format = scripts[globalmap[lind].scriptname].format;
18392 }
18393
18394 break;
18395 }
18396 case 12:
18397 //<<, ITEM
18398 {
18399 int32_t lind = assignscript_dlg[10].d1;
18400 int32_t rind = assignscript_dlg[11].d1;
18401
18402 if(lind < 0 || rind < 0)
18403 break;
18404
18405 if(asitemscripts[rind] == "<none>")
18406 {
18407 itemmap[lind].scriptname = "";
18408 itemmap[lind].format = SCRIPT_FORMAT_DEFAULT;
18409 }
18410 else
18411 {
18412 itemmap[lind].updateName(asitemscripts[rind]);
18413 itemmap[lind].format = scripts[itemmap[lind].scriptname].format;
18414 }
18415
18416 break;
18417 }
18418 case 20:
18419 //<<, NPC
18420 {
18421 int32_t lind = assignscript_dlg[18].d1;
18422 int32_t rind = assignscript_dlg[19].d1;
18423
18424 if(lind < 0 || rind < 0)
18425 break;
18426
18427 if(asnpcscripts[rind] == "<none>")
18428 {
18429 npcmap[lind].scriptname = "";
18430 npcmap[lind].format = SCRIPT_FORMAT_DEFAULT;
18431 }
18432 else
18433 {
18434 npcmap[lind].updateName(asnpcscripts[rind]);
18435 npcmap[lind].format = scripts[npcmap[lind].scriptname].format;
18436 }
18437
18438 break;
18439 }
18440 case 23:
18441 //<<, LWeapon
18442 {
18443 int32_t lind = assignscript_dlg[21].d1;
18444 int32_t rind = assignscript_dlg[22].d1;
18445
18446 if(lind < 0 || rind < 0)
18447 break;
18448
18449 if(aslweaponscripts[rind] == "<none>")
18450 {
18451 lwpnmap[lind].scriptname = "";
18452 lwpnmap[lind].format = SCRIPT_FORMAT_DEFAULT;
18453 }
18454 else
18455 {
18456 lwpnmap[lind].updateName(aslweaponscripts[rind]);
18457 lwpnmap[lind].format = scripts[lwpnmap[lind].scriptname].format;
18458 }
18459
18460 break;
18461 }
18462 case 26:
18463 //<<, EWeapon
18464 {
18465 int32_t lind = assignscript_dlg[24].d1;
18466 int32_t rind = assignscript_dlg[25].d1;
18467
18468 if(lind < 0 || rind < 0)
18469 break;
18470
18471 if(aseweaponscripts[rind] == "<none>")
18472 {
18473 ewpnmap[lind].scriptname = "";
18474 ewpnmap[lind].format = SCRIPT_FORMAT_DEFAULT;
18475 }
18476 else
18477 {
18478 ewpnmap[lind].updateName(aseweaponscripts[rind]);
18479 ewpnmap[lind].format = scripts[ewpnmap[lind].scriptname].format;
18480 }
18481
18482 break;
18483 }
18484 case 29:
18485 //<<, Hero
18486 {
18487 int32_t lind = assignscript_dlg[27].d1;
18488 int32_t rind = assignscript_dlg[28].d1;
18489
18490 if(lind < 0 || rind < 0)
18491 break;
18492
18493 if(asplayerscripts[rind] == "<none>")
18494 {
18495 playermap[lind].scriptname = "";
18496 playermap[lind].format = SCRIPT_FORMAT_DEFAULT;
18497 }
18498 else
18499 {
18500 playermap[lind].updateName(asplayerscripts[rind]);
18501 playermap[lind].format = scripts[playermap[lind].scriptname].format;
18502 }
18503
18504 break;
18505 }
18506 case 32:
18507 //<<, Screendata
18508 {
18509 int32_t lind = assignscript_dlg[30].d1;
18510 int32_t rind = assignscript_dlg[31].d1;
18511
18512 if(lind < 0 || rind < 0)
18513 break;
18514
18515 if(asscreenscripts[rind] == "<none>")
18516 {
18517 screenmap[lind].scriptname = "";
18518 screenmap[lind].format = SCRIPT_FORMAT_DEFAULT;
18519 }
18520 else
18521 {
18522 screenmap[lind].updateName(asscreenscripts[rind]);
18523 screenmap[lind].format = scripts[screenmap[lind].scriptname].format;
18524 }
18525
18526 break;
18527 }
18528 case 35:
18529 //<<, dmapdata
18530 {
18531 int32_t lind = assignscript_dlg[33].d1;
18532 int32_t rind = assignscript_dlg[34].d1;
18533
18534 if(lind < 0 || rind < 0)
18535 break;
18536
18537 if(asdmapscripts[rind] == "<none>")
18538 {
18539 dmapmap[lind].scriptname = "";
18540 dmapmap[lind].format = SCRIPT_FORMAT_DEFAULT;
18541 }
18542 else
18543 {
18544 dmapmap[lind].updateName(asdmapscripts[rind]);
18545 dmapmap[lind].format = scripts[dmapmap[lind].scriptname].format;
18546 }
18547
18548 break;
18549 }
18550 case 38:
18551 //<<, itemsprite
18552 {
18553 int32_t lind = assignscript_dlg[36].d1;
18554 int32_t rind = assignscript_dlg[37].d1;
18555
18556 if(lind < 0 || rind < 0)
18557 break;
18558
18559 if(asitemspritescripts[rind] == "<none>")
18560 {
18561 itemspritemap[lind].scriptname = "";
18562 itemspritemap[lind].format = SCRIPT_FORMAT_DEFAULT;
18563 }
18564 else
18565 {
18566 itemspritemap[lind].updateName(asitemspritescripts[rind]);
18567 itemspritemap[lind].format = scripts[itemspritemap[lind].scriptname].format;
18568 }
18569
18570 break;
18571 }
18572 case 41:
18573 //<<, comboscript
18574 {
18575 int32_t lind = assignscript_dlg[39].d1;
18576 int32_t rind = assignscript_dlg[40].d1;
18577
18578 if(lind < 0 || rind < 0)
18579 break;
18580
18581 if(ascomboscripts[rind] == "<none>")
18582 {
18583 comboscriptmap[lind].scriptname = "";
18584 comboscriptmap[lind].format = SCRIPT_FORMAT_DEFAULT;
18585 }
18586 else
18587 {
18588 comboscriptmap[lind].updateName(ascomboscripts[rind]);
18589 comboscriptmap[lind].format = scripts[comboscriptmap[lind].scriptname].format;
18590 }
18591
18592 break;
18593 }
18594 case 47:
18595 //<<, generic script
18596 {
18597 int32_t lind = assignscript_dlg[45].d1;
18598 int32_t rind = assignscript_dlg[46].d1;
18599
18600 if(lind < 0 || rind < 0)
18601 break;
18602
18603 if(asgenericscripts[rind] == "<none>")
18604 {
18605 genericmap[lind].scriptname = "";
18606 genericmap[lind].format = SCRIPT_FORMAT_DEFAULT;
18607 }
18608 else
18609 {
18610 genericmap[lind].updateName(asgenericscripts[rind]);
18611 genericmap[lind].format = scripts[genericmap[lind].scriptname].format;
18612 }
18613
18614 break;
18615 }
18616 case 50:
18617 //<<, subscreen script
18618 {
18619 int32_t lind = assignscript_dlg[48].d1;
18620 int32_t rind = assignscript_dlg[49].d1;
18621
18622 if(lind < 0 || rind < 0)
18623 break;
18624
18625 if(assubscreenscripts[rind] == "<none>")
18626 {
18627 subscreenmap[lind].scriptname = "";
18628 subscreenmap[lind].format = SCRIPT_FORMAT_DEFAULT;
18629 }
18630 else
18631 {
18632 subscreenmap[lind].updateName(assubscreenscripts[rind]);
18633 subscreenmap[lind].format = scripts[subscreenmap[lind].scriptname].format;
18634 }
18635
18636 break;
18637 }
18638
18639 case 42:
18640 //Script Info, information
18641 {
18642 disassembled_script_data* target = nullptr;
18643 switch(get_selected_tab((TABPANEL*)assignscript_dlg[1].dp))
18644 {
18645 default:
18646 case 0: //FFC
18647 {
18648 int32_t id = assignscript_dlg[4].d1;
18649 if(id > -1 && ffcmap[id].hasScriptData())
18650 {
18651 target = &(scripts[ffcmap[id].scriptname]);
18652 }
18653 break;
18654 }
18655 case 1: //Global
18656 {
18657 int32_t id = assignscript_dlg[7].d1;
18658 if(id > -1 && globalmap[id].hasScriptData())
18659 {
18660 target = &(scripts[globalmap[id].scriptname]);
18661 }
18662 break;
18663 }
18664 case 2: //Item
18665 {
18666 int32_t id = assignscript_dlg[10].d1;
18667 if(id > -1 && itemmap[id].hasScriptData())
18668 {
18669 target = &(scripts[itemmap[id].scriptname]);
18670 }
18671 break;
18672 }
18673 case 3: //npc
18674 {
18675 int32_t id = assignscript_dlg[19].d1;
18676 if(id > -1 && npcmap[id].hasScriptData())
18677 {
18678 target = &(scripts[npcmap[id].scriptname]);
18679 }
18680 break;
18681 }
18682 case 4: //lweapon
18683 {
18684 int32_t id = assignscript_dlg[21].d1;
18685 if(id > -1 && lwpnmap[id].hasScriptData())
18686 {
18687 target = &(scripts[lwpnmap[id].scriptname]);
18688 }
18689 break;
18690 }
18691 case 5: //eweapon
18692 {
18693 int32_t id = assignscript_dlg[24].d1;
18694 if(id > -1 && ewpnmap[id].hasScriptData())
18695 {
18696 target = &(scripts[ewpnmap[id].scriptname]);
18697 }
18698 break;
18699 }
18700 case 6: //hero
18701 {
18702 int32_t id = assignscript_dlg[27].d1;
18703 if(id > -1 && playermap[id].hasScriptData())
18704 {
18705 target = &(scripts[playermap[id].scriptname]);
18706 }
18707 break;
18708 }
18709 case 7: //dmap
18710 {
18711 int32_t id = assignscript_dlg[33].d1;
18712 if(id > -1 && dmapmap[id].hasScriptData())
18713 {
18714 target = &(scripts[dmapmap[id].scriptname]);
18715 }
18716 break;
18717 }
18718 case 8: //screen
18719 {
18720 int32_t id = assignscript_dlg[30].d1;
18721 if(id > -1 && screenmap[id].hasScriptData())
18722 {
18723 target = &(scripts[screenmap[id].scriptname]);
18724 }
18725 break;
18726 }
18727 case 9: //itemsprite
18728 {
18729 int32_t id = assignscript_dlg[36].d1;
18730 if(id > -1 && itemspritemap[id].hasScriptData())
18731 {
18732 target = &(scripts[itemspritemap[id].scriptname]);
18733 }
18734 break;
18735 }
18736 case 10: //combo
18737 {
18738 int32_t id = assignscript_dlg[39].d1;
18739 if(id > -1 && comboscriptmap[id].hasScriptData())
18740 {
18741 target = &(scripts[comboscriptmap[id].scriptname]);
18742 }
18743 break;
18744 }
18745 case 11: //Generic
18746 {
18747 int32_t id = assignscript_dlg[45].d1;
18748 if(id > -1 && genericmap[id].hasScriptData())
18749 {
18750 target = &(scripts[genericmap[id].scriptname]);
18751 }
18752 break;
18753 }
18754 case 12: //Subscreen
18755 {
18756 int32_t id = assignscript_dlg[48].d1;
18757 if(id > -1 && subscreenmap[id].hasScriptData())
18758 {
18759 target = &(scripts[subscreenmap[id].scriptname]);
18760 }
18761 break;
18762 }
18763 }
18764 if(target)
18765 showScriptInfo(&target->meta);
18766 break;
18767 }
18768
18769 case 43:
18770 //Script Info, information
18771 {
18772 disassembled_script_data* target = NULL;
18773 switch(get_selected_tab((TABPANEL*)assignscript_dlg[1].dp))
18774 {
18775 default:
18776 case 0: //FFC
18777 {
18778 int32_t id = assignscript_dlg[5].d1;
18779 if(id < 0 || asffcscripts[id] == "<none>" || asffcscripts[id].at(0) == '-') break;
18780 target = &(scripts[asffcscripts[id]]);
18781 break;
18782 }
18783 case 1: //Global
18784 {
18785 int32_t id = assignscript_dlg[8].d1;
18786 if(id < 0 || asglobalscripts[id] == "<none>" || asglobalscripts[id].at(0) == '-') break;
18787 target = &(scripts[asglobalscripts[id]]);
18788 break;
18789 }
18790 case 2: //Item
18791 {
18792 int32_t id = assignscript_dlg[11].d1;
18793 if(id < 0 || asitemscripts[id] == "<none>" || asitemscripts[id].at(0) == '-') break;
18794 target = &(scripts[asitemscripts[id]]);
18795 break;
18796 }
18797 case 3: //npc
18798 {
18799 int32_t id = assignscript_dlg[20].d1;
18800 if(id < 0 || asnpcscripts[id] == "<none>" || asnpcscripts[id].at(0) == '-') break;
18801 target = &(scripts[asnpcscripts[id]]);
18802 break;
18803 }
18804 case 4: //lweapon
18805 {
18806 int32_t id = assignscript_dlg[22].d1;
18807 if(id < 0 || aslweaponscripts[id] == "<none>" || aslweaponscripts[id].at(0) == '-') break;
18808 target = &(scripts[aslweaponscripts[id]]);
18809 break;
18810 }
18811 case 5: //eweapon
18812 {
18813 int32_t id = assignscript_dlg[25].d1;
18814 if(id < 0 || aseweaponscripts[id] == "<none>" || aseweaponscripts[id].at(0) == '-') break;
18815 target = &(scripts[aseweaponscripts[id]]);
18816 break;
18817 }
18818 case 6: //hero
18819 {
18820 int32_t id = assignscript_dlg[28].d1;
18821 if(id < 0 || asplayerscripts[id] == "<none>" || asplayerscripts[id].at(0) == '-') break;
18822 target = &(scripts[asplayerscripts[id]]);
18823 break;
18824 }
18825 case 7: //dmap
18826 {
18827 int32_t id = assignscript_dlg[34].d1;
18828 if(id < 0 || asdmapscripts[id] == "<none>" || asdmapscripts[id].at(0) == '-') break;
18829 target = &(scripts[asdmapscripts[id]]);
18830 break;
18831 }
18832 case 8: //screen
18833 {
18834 int32_t id = assignscript_dlg[31].d1;
18835 if(id < 0 || asscreenscripts[id] == "<none>" || asscreenscripts[id].at(0) == '-') break;
18836 target = &(scripts[asscreenscripts[id]]);
18837 break;
18838 }
18839 case 9: //itemsprite
18840 {
18841 int32_t id = assignscript_dlg[37].d1;
18842 if(id < 0 || asitemspritescripts[id] == "<none>" || asitemspritescripts[id].at(0) == '-') break;
18843 target = &(scripts[asitemspritescripts[id]]);
18844 break;
18845 }
18846 case 10: //combo
18847 {
18848 int32_t id = assignscript_dlg[40].d1;
18849 if(id < 0 || ascomboscripts[id] == "<none>" || ascomboscripts[id].at(0) == '-') break;
18850 target = &(scripts[ascomboscripts[id]]);
18851 break;
18852 }
18853 case 11: //generic
18854 {
18855 int32_t id = assignscript_dlg[46].d1;
18856 if(id < 0 || asgenericscripts[id] == "<none>" || asgenericscripts[id].at(0) == '-') break;
18857 target = &(scripts[asgenericscripts[id]]);
18858 break;
18859 }
18860 case 12: //subscreen
18861 {
18862 int32_t id = assignscript_dlg[49].d1;
18863 if(id < 0 || assubscreenscripts[id] == "<none>" || assubscreenscripts[id].at(0) == '-') break;
18864 target = &(scripts[assubscreenscripts[id]]);
18865 break;
18866 }
18867 }
18868 if(target)
18869 showScriptInfo(&target->meta);
18870 break;
18871 }
18872
18873 case 44:
18874 //Clear, clear slots of current type- after a confirmation.
18875 {
18876 doClearSlots(&slotflags);
18877 break;
18878 }
18879 }
18880 }
18881
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(assign_mode == 2) //Smart Assign
18882 {
18883 //For global/hero scripts, match slot names if unoccupied
18884 smart_slot_named(scripts, asglobalscripts, globalmap, global_slotnames, 1, NUMSCRIPTGLOBAL);
18885 smart_slot_named(scripts, asplayerscripts, playermap, player_slotnames, 0, NUMSCRIPTHERO-1);
18886 //For other scripts, assign all un-assigned scripts
18887 smart_slot_type(scripts, asffcscripts, ffcmap, NUMSCRIPTFFC-1);
18888 smart_slot_type(scripts, asitemscripts, itemmap, NUMSCRIPTITEM-1);
18889 smart_slot_type(scripts, asnpcscripts, npcmap, NUMSCRIPTGUYS-1);
18890 smart_slot_type(scripts, aslweaponscripts, lwpnmap, NUMSCRIPTWEAPONS-1);
18891 smart_slot_type(scripts, aseweaponscripts, ewpnmap, NUMSCRIPTWEAPONS-1);
18892 smart_slot_type(scripts, asscreenscripts, screenmap, NUMSCRIPTSCREEN-1);
18893 smart_slot_type(scripts, asdmapscripts, dmapmap, NUMSCRIPTSDMAP-1);
18894 smart_slot_type(scripts, asitemspritescripts, itemspritemap, NUMSCRIPTSITEMSPRITE-1);
18895 smart_slot_type(scripts, ascomboscripts, comboscriptmap, NUMSCRIPTSCOMBODATA-1);
18896 smart_slot_type(scripts, asgenericscripts, genericmap, NUMSCRIPTSGENERIC-1);
18897 smart_slot_type(scripts, assubscreenscripts, subscreenmap, NUMSCRIPTSSUBSCREEN-1);
18898 }
18899 auto_do_slots:
18900 6 doslots_log_output = (assignscript_dlg[13].flags == D_SELECTED);
18901 6 doslots_comment_output = (assignscript_dlg[51].flags == D_SELECTED);
18902 6 doslot_scripts = &scripts;
18903 //OK
18904 {
18905
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(doslots_log_output)
18906 {
18907 string outstr;
18908 write_script(zasm, outstr, doslots_comment_output, doslot_scripts);
18909 safe_al_trace(outstr);
18910 }
18911 6 auto start_assign_time = std::chrono::steady_clock::now();
18912 6 string zasm_str;
18913
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 write_script(zasm, zasm_str, false, nullptr);
18914
18915 6 std::vector<ffscript> zasm;
18916
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(parse_script_string(zasm, zasm_str, false))
18917 goto exit_do_slots;
18918
18919 6 zasm_scripts.clear();
18920
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 zasm_scripts.emplace_back(std::make_shared<zasm_script>(std::move(zasm)));
18921
18922
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!handle_slot_map(ffcmap, 1, ffscripts))
18923 goto exit_do_slots;
18924
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!handle_slot_map(globalmap, 0, globalscripts))
18925 goto exit_do_slots;
18926
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!handle_slot_map(itemmap, 1, itemscripts))
18927 goto exit_do_slots;
18928
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!handle_slot_map(npcmap, 1, guyscripts))
18929 goto exit_do_slots;
18930
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!handle_slot_map(lwpnmap, 1, lwpnscripts))
18931 goto exit_do_slots;
18932
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!handle_slot_map(ewpnmap, 1, ewpnscripts))
18933 goto exit_do_slots;
18934
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!handle_slot_map(playermap, 1, playerscripts))
18935 goto exit_do_slots;
18936
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!handle_slot_map(dmapmap, 1, dmapscripts))
18937 goto exit_do_slots;
18938
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!handle_slot_map(screenmap, 1, screenscripts))
18939 goto exit_do_slots;
18940
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!handle_slot_map(itemspritemap, 1, itemspritescripts))
18941 goto exit_do_slots;
18942
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!handle_slot_map(comboscriptmap, 1, comboscripts))
18943 goto exit_do_slots;
18944
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!handle_slot_map(genericmap, 1, genericscripts))
18945 goto exit_do_slots;
18946
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!handle_slot_map(subscreenmap, 1, subscreenscripts))
18947 goto exit_do_slots;
18948
18949 6 auto end_assign_time = std::chrono::steady_clock::now();
18950
3/6
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
6 int compile_time_ms = std::chrono::duration_cast<std::chrono::milliseconds>(end_assign_time - start_assign_time).count();
18951
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 al_trace("Assign Slots took %d ms\n", compile_time_ms);
18952 6 char buf[256] = {0};
18953 12 sprintf(buf, "ZScripts successfully loaded into script slots"
18954 6 "\nAssign Slots took %d ms", compile_time_ms);
18955
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 auto sfx_id = vbound(zc_get_config("Compiler","compile_finish_sample",20),0,255);
18956
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 auto sfx_vol = vbound(zc_get_config("Compiler","compile_audio_volume",100),0,255);
18957
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if ( sfx_id > 0 && sfx_vol > 0)
18958
3/6
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
6 sfx(sfx_id, 128, false, true, sfx_vol / 1.28_zf);
18959
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!assign_mode)
18960 InfoDialog("Slots Assigned",buf).show();
18961
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 kill_sfx();
18962 6 retval = true;
18963 6 goto exit_do_slots;
18964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 }
18965 exit_do_slots:
18966 6 doslot_scripts = nullptr;
18967 6 popup_zqdialog_end();
18968 6 return retval;
18969 }
18970
18971 static char slottype_str_buf[32];
18972
18973 const char *slottype_list(int32_t index, int32_t *list_size)
18974 {
18975 if(index >= 0)
18976 {
18977 bound(index,0,num_types-1);
18978
18979 switch(index)
18980 {
18981 case type_ffc:
18982 strcpy(slottype_str_buf, "FFC");
18983 break;
18984 case type_global:
18985 strcpy(slottype_str_buf, "Global");
18986 break;
18987 case type_itemdata:
18988 strcpy(slottype_str_buf, "Item");
18989 break;
18990 case type_npc:
18991 strcpy(slottype_str_buf, "NPC");
18992 break;
18993 case type_lweapon:
18994 strcpy(slottype_str_buf, "LWeapon");
18995 break;
18996 case type_eweapon:
18997 strcpy(slottype_str_buf, "EWeapon");
18998 break;
18999 case type_hero:
19000 strcpy(slottype_str_buf, "Hero");
19001 break;
19002 case type_dmap:
19003 strcpy(slottype_str_buf, "DMap");
19004 break;
19005 case type_screen:
19006 strcpy(slottype_str_buf, "Screen");
19007 break;
19008 case type_itemsprite:
19009 strcpy(slottype_str_buf, "ItemSprite");
19010 break;
19011 case type_combo:
19012 strcpy(slottype_str_buf, "Combo");
19013 break;
19014 case type_generic:
19015 strcpy(slottype_str_buf, "Generic");
19016 break;
19017 case type_subscreen:
19018 strcpy(slottype_str_buf, "Subscreen");
19019 break;
19020 }
19021
19022 return slottype_str_buf;
19023 }
19024 *list_size = 11;
19025 return NULL;
19026 }
19027 12 static ListData slottype_sel_list(slottype_list, &font);
19028
19029 static DIALOG clearslots_dlg[] =
19030 {
19031 12 { jwin_win_proc, 0, 0, 200, 159, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Clear Slots", NULL, NULL },
19032 12 { jwin_button_proc, 35, 132, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Confirm", NULL, NULL },
19033 12 { jwin_button_proc, 104, 132, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
19034 12 { jwin_droplist_proc, 50, 28+16, 70, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &slottype_sel_list, NULL, NULL },
19035 12 { jwin_radio_proc, 40, 34+00, 81, 9, vc(14), vc(1), 0, D_SELECTED, 0, 0, (void *) "Clear Script Type:", NULL, NULL },
19036 12 { jwin_radio_proc, 40, 34+32, 81, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear Missing (--) Slots", NULL, NULL },
19037 12 { jwin_radio_proc, 40, 34+80, 81, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear All", NULL, NULL },
19038 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
19039 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
19040 };
19041
19042 void doClearSlots(byte* flags)
19043 {
19044 //{ Setup
19045 clearslots_dlg[0].dp2=get_zc_font(font_lfont);
19046 clearslots_dlg[3].d1 = get_selected_tab((TABPANEL*)assignscript_dlg[1].dp); //Default to current tab's type
19047 clearslots_dlg[4].flags |= D_SELECTED;
19048 clearslots_dlg[5].flags &= ~D_SELECTED;
19049 clearslots_dlg[6].flags &= ~D_SELECTED;
19050 if(((*flags) & SLOTMSGFLAG_MISSING) == 0)
19051 clearslots_dlg[5].flags |= D_DISABLED;
19052 else
19053 clearslots_dlg[5].flags &= ~D_DISABLED;
19054 //}
19055
19056 large_dialog(clearslots_dlg);
19057
19058 if(do_zqdialog(clearslots_dlg,2)==1)
19059 {
19060 int32_t q = 3;
19061 while((clearslots_dlg[++q].flags & D_SELECTED) == 0);
19062 switch(q)
19063 {
19064 case 4: //Clear type
19065 {
19066 clearAllSlots(clearslots_dlg[3].d1);
19067 break;
19068 }
19069 case 5: //Clear Missing
19070 {
19071 for(int32_t q = 0; q <= 10; ++q)
19072 clearAllSlots(q,SLOTMSGFLAG_MISSING);
19073 break;
19074 }
19075 case 6: //Clear ALL
19076 {
19077 for(int32_t q = 0; q <= 10; ++q)
19078 clearAllSlots(q);
19079 break;
19080 }
19081 }
19082 }
19083 }
19084
19085 static DIALOG exportzasm_dlg[] =
19086 {
19087 12 { jwin_win_proc, 0, 0, 200, 159, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Export ZASM", NULL, NULL },
19088 12 { jwin_button_proc, 35, 132, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Confirm", NULL, NULL },
19089 12 { jwin_button_proc, 104, 132, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
19090 12 { jwin_droplist_proc, 50, 28+16, 100, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, (void *) &slottype_sel_list, NULL, NULL },
19091 12 { jwin_droplist_proc, 50, 28+48, 100, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
19092 12 { jwin_text_proc, 50, 28+8, 16, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Script Type:", NULL, NULL },
19093 12 { jwin_text_proc, 50, 28+40, 16, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Script Slot:", NULL, NULL },
19094 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
19095 };
19096
19097 static DIALOG importzasm_dlg[] =
19098 {
19099 12 { jwin_win_proc, 0, 0, 200, 159, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Import ZASM", NULL, NULL },
19100 12 { jwin_button_proc, 35, 132, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Confirm", NULL, NULL },
19101 12 { jwin_button_proc, 104, 132, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
19102 12 { jwin_droplist_proc, 50, 28+16, 100, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, (void *) &slottype_sel_list, NULL, NULL },
19103 12 { jwin_droplist_proc, 50, 28+48, 100, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
19104 // 5
19105 12 { jwin_text_proc, 50, 28+8, 16, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Script Type:", NULL, NULL },
19106 12 { jwin_text_proc, 50, 28+40, 16, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Script Slot:", NULL, NULL },
19107 12 { jwin_text_proc, 50, 28+72, 16, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Script Name:", NULL, NULL },
19108 12 { jwin_edit_proc, 50, 28+80, 100, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 19, 0, NULL, NULL, NULL },
19109
19110 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
19111 };
19112
19113 1 void center_zscript_dialogs()
19114 {
19115 1 jwin_center_dialog(exportzasm_dlg);
19116 1 jwin_center_dialog(importzasm_dlg);
19117 1 jwin_center_dialog(clearslots_dlg);
19118 1 }
19119
19120 // array of voices, one for each sfx sample in the data file
19121 // 0+ = voice #
19122 // -1 = voice not allocated
19123 int32_t sfx_voice[WAV_COUNT];
19124
19125 void Z_init_sound()
19126 {
19127 for(int32_t i=0; i<WAV_COUNT; i++)
19128 sfx_voice[i]=-1;
19129
19130 // master_volume(digi_volume,midi_volume);
19131 }
19132
19133 // returns number of voices currently allocated
19134 int32_t sfx_count()
19135 {
19136 int32_t c=0;
19137
19138 for(int32_t i=0; i<WAV_COUNT; i++)
19139 if(sfx_voice[i]!=-1)
19140 ++c;
19141
19142 return c;
19143 }
19144
19145 // clean up finished samples
19146 void sfx_cleanup()
19147 {
19148 for(int32_t i=0; i<WAV_COUNT; i++)
19149 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
19150 {
19151 deallocate_voice(sfx_voice[i]);
19152 sfx_voice[i]=-1;
19153 }
19154 }
19155
19156 bool sfx_templist = false;
19157 SAMPLE templist[WAV_COUNT];
19158 12 SAMPLE* sfx_get_sample(int32_t index)
19159 {
19160 // check index
19161
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 if (index<=0 || index>=WAV_COUNT)
19162 return nullptr;
19163
19164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (sfx_templist)
19165 {
19166 if (templist[index].data)
19167 return &templist[index];
19168 else return nullptr;
19169 }
19170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 else if (sfxdat)
19171 {
19172 if (index<Z35)
19173 {
19174 return (SAMPLE*)sfxdata[index].dat;
19175 }
19176 else
19177 {
19178 return (SAMPLE*)sfxdata[Z35].dat;
19179 }
19180 }
19181 else
19182 {
19183 12 return &customsfxdata[index];
19184 }
19185
19186 return nullptr;
19187 12 }
19188
19189 12 bool sfx_init(int32_t index)
19190 {
19191 // check index
19192
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 if(index<1 || index>=WAV_COUNT)
19193 return false;
19194
19195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(sfx_voice[index]==-1)
19196 {
19197 12 SAMPLE* sample = sfx_get_sample(index);
19198
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if (!sample)
19199 return false;
19200
19201 12 sfx_voice[index] = allocate_voice(sample);
19202 12 }
19203
19204 12 return sfx_voice[index] != -1;
19205 12 }
19206
19207 // plays an sfx sample
19208 12 void sfx(int32_t index,int32_t pan,bool loop,bool restart,zfix vol_perc,int32_t freq)
19209 {
19210
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!sfx_init(index))
19211 return;
19212
19213 12 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
19214 12 voice_set_pan(sfx_voice[index],pan);
19215
19216 12 int32_t pos = voice_get_position(sfx_voice[index]);
19217
19218 12 int temp_volume = (128 * (vol_perc / 100)).getFloor();
19219
19220
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(restart) voice_set_position(sfx_voice[index],0);
19221 12 voice_set_volume(sfx_voice[index], temp_volume);
19222
19223
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(pos<=0)
19224 12 voice_start(sfx_voice[index]);
19225 12 }
19226
19227 // start it (in loop mode) if it's not already playing,
19228 // otherwise just leave it in its current position
19229 void cont_sfx(int32_t index)
19230 {
19231 if(!sfx_init(index))
19232 return;
19233
19234 if(voice_get_position(sfx_voice[index])<=0)
19235 {
19236 voice_set_position(sfx_voice[index],0);
19237 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
19238 voice_start(sfx_voice[index]);
19239 }
19240 }
19241
19242 // adjust parameters while playing
19243 void adjust_sfx(int32_t index,int32_t pan,bool loop)
19244 {
19245 if(index<0 || index>=WAV_COUNT || sfx_voice[index]==-1)
19246 return;
19247
19248 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
19249 voice_set_pan(sfx_voice[index],pan);
19250 }
19251
19252 // pauses a voice
19253 void pause_sfx(int32_t index)
19254 {
19255 if(index>=0 && index<WAV_COUNT && sfx_voice[index]!=-1)
19256 voice_stop(sfx_voice[index]);
19257 }
19258
19259 // resumes a voice
19260 void resume_sfx(int32_t index)
19261 {
19262 if(index>=0 && index<WAV_COUNT && sfx_voice[index]!=-1)
19263 voice_start(sfx_voice[index]);
19264 }
19265
19266 // pauses all active voices
19267 void pause_all_sfx()
19268 {
19269 for(int32_t i=0; i<WAV_COUNT; i++)
19270 if(sfx_voice[i]!=-1)
19271 voice_stop(sfx_voice[i]);
19272 }
19273
19274 // resumes all paused voices
19275 void resume_all_sfx()
19276 {
19277 for(int32_t i=0; i<WAV_COUNT; i++)
19278 if(sfx_voice[i]!=-1)
19279 voice_start(sfx_voice[i]);
19280 }
19281
19282 // stops an sfx and deallocates the voice
19283 void stop_sfx(int32_t index)
19284 {
19285 if(index<0 || index>=WAV_COUNT)
19286 return;
19287
19288 if(sfx_voice[index]!=-1)
19289 {
19290 deallocate_voice(sfx_voice[index]);
19291 sfx_voice[index]=-1;
19292 }
19293 }
19294
19295 18 void kill_sfx()
19296 {
19297
2/2
✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 18 times.
4626 for(int32_t i=0; i<WAV_COUNT; i++)
19298
2/2
✓ Branch 0 taken 3060 times.
✓ Branch 1 taken 1548 times.
6156 if(sfx_voice[i]!=-1)
19299 {
19300 1548 deallocate_voice(sfx_voice[i]);
19301 1548 sfx_voice[i]=-1;
19302 1548 }
19303 18 }
19304
19305 int32_t pan(int32_t x)
19306 {
19307 return 128;
19308 /*switch(pan_style)
19309 {
19310 case 0: return 128;
19311 case 1: return vbound((x>>1)+68,0,255);
19312 case 2: return vbound(((x*3)>>2)+36,0,255);
19313 }
19314 return vbound(x,0,255);*/
19315 }
19316
19317
19318 void change_sfx(SAMPLE *sfx1, SAMPLE *sfx2)
19319 {
19320 sfx1->bits = sfx2->bits;
19321 sfx1->stereo = sfx2->stereo;
19322 sfx1->freq = sfx2->freq;
19323 sfx1->priority = sfx2->priority;
19324 sfx1->len = sfx2->len;
19325 sfx1->loop_start = sfx2->loop_start;
19326 sfx1->loop_end = sfx2->loop_end;
19327 sfx1->param = sfx2->param;
19328
19329 if(sfx1->data != NULL)
19330 {
19331 free(sfx1->data);
19332 }
19333
19334 if(sfx2->data == NULL)
19335 sfx1->data = NULL;
19336 else
19337 {
19338 // When quests are saved and loaded, data is written in words.
19339 // If the last byte is dropped, it'll cause the sound to end with
19340 // a click. It could simply be extended and padded with 0, but
19341 // that causes compatibility issues... So we'll cut off
19342 // the last byte and decrease the length.
19343
19344 int32_t len = (sfx1->bits==8?1:2)*(sfx1->stereo == 0 ? 1 : 2)*sfx1->len;
19345
19346 while(len%sizeof(word))
19347 {
19348 // sizeof(word) should be 2, so this doesn't really need
19349 // to be a loop, but what the heck.
19350 sfx1->len--;
19351 len = (sfx1->bits==8?1:2)*(sfx1->stereo == 0 ? 1 : 2)*sfx1->len;
19352 }
19353
19354 sfx1->data = malloc(len);
19355 memcpy(sfx1->data, sfx2->data, len);
19356 }
19357 }
19358
19359 bool confirmBox(const char *m1, const char *m2, const char *m3)
19360 {
19361 if(!m3)
19362 {
19363 if(!m2) m2 = "Are you sure?";
19364 else m3 = "Are you sure?";
19365 }
19366 return jwin_alert("Confirmation", m1, m2, m3, "Yes", "No", 'y', 'n', get_zc_font(font_lfont)) == 1;
19367 }
19368
19369 int32_t onSelectSFX()
19370 {
19371 SFXListerDialog(0).show();
19372 refresh(rMAP+rCOMBOS);
19373 return D_O_K;
19374 }
19375
19376 bool saveWAV(int32_t slot, const char *filename)
19377 {
19378 if (slot < 1 || slot >= 511 )
19379 return false;
19380
19381 if (customsfxdata[slot].data == NULL)
19382 return false;
19383
19384 std::ofstream ofs(filename, std::ios::binary);
19385 if (!ofs)
19386 return false;
19387 ofs.write("RIFF",4);
19388 uint32_t samplerate = customsfxdata[slot].freq;
19389 uint16_t channels = customsfxdata[slot].stereo ? 2 : 1;
19390 uint32_t datalen = customsfxdata[slot].len*channels*customsfxdata[slot].bits / 8;
19391 uint32_t size = 36 + datalen;
19392 ofs.write((char *)&size, 4);
19393 ofs.write("WAVE", 4);
19394 ofs.write("fmt ", 4);
19395 uint32_t fmtlen = 16;
19396 ofs.write((char *)&fmtlen, 4);
19397 uint16_t type = 1;
19398 ofs.write((char *)&type, 2);
19399 ofs.write((char *)&channels, 2);
19400 ofs.write((char *)&samplerate, 4);
19401 uint32_t bytespersec = samplerate*channels*customsfxdata[slot].bits / 8;
19402 ofs.write((char *)&bytespersec, 4);
19403 uint16_t blockalign = channels*customsfxdata[slot].bits / 8;
19404 ofs.write((char *)&blockalign, 2);
19405 uint16_t bitspersample = customsfxdata[slot].bits;
19406 ofs.write((char *)&bitspersample, 2);
19407 ofs.write("data", 4);
19408 ofs.write((char *)&datalen, 4);
19409 if (bitspersample == 8)
19410 {
19411 for (int32_t i = 0; i < (int32_t)customsfxdata[slot].len*channels; i++)
19412 {
19413 char data = ((char *)customsfxdata[slot].data)[i];
19414 data ^= 0x80;
19415 ofs.write(&data, 1);
19416 }
19417 }
19418 else if (bitspersample == 16)
19419 {
19420 for (int32_t i = 0; i < (int32_t)customsfxdata[slot].len*channels; i++)
19421 {
19422 uint16_t data = ((uint16_t *)customsfxdata[slot].data)[i];
19423 data ^= 0x8000;
19424 ofs.write((char *)&data, 2);
19425 }
19426 }
19427 else
19428 return false;
19429 return !!ofs;
19430 }
19431
19432 int32_t onMapStyles()
19433 {
19434 call_mapstyles_dialog();
19435 return D_O_K;
19436 }
19437
19438 int32_t d_misccolors_old_proc(int32_t msg,DIALOG *d,int32_t c)
19439 {
19440 //these are here to bypass compiler warnings about unused arguments
19441 c=c;
19442
19443 if(msg==MSG_DRAW)
19444 {
19445 textout_ex(screen,font,"0123456789ABCDEF",d->x+8,d->y,d->fg,d->bg);
19446 textout_ex(screen,font,"0",d->x,d->y+8,d->fg,d->bg);
19447 textout_ex(screen,font,"1",d->x,d->y+16,d->fg,d->bg);
19448 textout_ex(screen,font,"5",d->x,d->y+24,d->fg,d->bg);
19449
19450 for(int32_t i=0; i<32; i++)
19451 {
19452 int32_t px2 = d->x+((i&15)<<3)+8;
19453 int32_t py2 = d->y+((i>>4)<<3)+8;
19454 rectfill(screen,px2,py2,px2+7,py2+7,i);
19455 }
19456
19457 for(int32_t i=0; i<16; i++)
19458 {
19459 int32_t px2 = d->x+(i<<3)+8;
19460 rectfill(screen,px2,d->y+24,px2+7,d->y+31,i+80);
19461 }
19462 }
19463
19464 return D_O_K;
19465 }
19466
19467 int32_t hexclicked=-1;
19468
19469 int32_t d_misccolors_hexedit_proc(int32_t msg,DIALOG *d,int32_t c)
19470 {
19471 switch(msg)
19472 {
19473 case MSG_GOTFOCUS:
19474 hexclicked=((int32_t)(size_t)(d->dp3))+20;
19475 break;
19476
19477 case MSG_LOSTFOCUS:
19478 hexclicked=-1;
19479 break;
19480 }
19481
19482 return d_hexedit_proc(msg,d,c);
19483 }
19484
19485
19486 int32_t d_misccolors_proc(int32_t msg,DIALOG *d,int32_t c);
19487
19488 static int32_t misccolor1_list[] =
19489 {
19490 // dialog control number
19491 4, 5, 6, 7, 8, 20, 21, 22, 23, 24, 36, 37, 38, 39, 40, -1
19492 };
19493
19494 static int32_t misccolor2_list[] =
19495 {
19496 // dialog control number
19497 9, 10, 11, 12, 13, 25, 26, 27, 28, 29, 41, 42, 43, 44, 45, -1
19498 };
19499
19500 static int32_t misccolor3_list[] =
19501 {
19502 // dialog control number
19503 14, 15, 16, 17, 18, 30, 31, 32, 33, 34, 46, 47, 48, 49, 50, -1
19504 };
19505
19506 static int32_t misccolor4_list[] =
19507 {
19508 19, 35, 51, 54, 55, 56, -1
19509 };
19510
19511 static TABPANEL misccolor_tabs[] =
19512 {
19513 // (text)
19514 { (char *)"1", D_SELECTED, misccolor1_list, 0, NULL },
19515 { (char *)"2", 0, misccolor2_list, 0, NULL },
19516 { (char *)"3", 0, misccolor3_list, 0, NULL },
19517 { (char *)"4", 0, misccolor4_list, 0, NULL },
19518 { NULL, 0, NULL, 0, NULL }
19519 };
19520
19521 int32_t d_misccolors_tab_proc(int32_t msg,DIALOG *d,int32_t c);
19522
19523 static DIALOG misccolors_dlg[] =
19524 {
19525 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
19526 12 { jwin_win_proc, 2, 21, 316, 197-23, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Misc Colors", NULL, NULL },
19527 // { jwin_frame_proc, 98-84+1+2, 52+8-6+4, 132, 100, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
19528 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
19529 12 { d_misccolors_proc, 92-84+1+2, 44+8-6+4, 128+8, 96+8, vc(9), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
19530 //3
19531 12 { d_misccolors_tab_proc, 150+14-2+10-15, 60-14, 150-10+15, 144-20-10, jwin_pal[jcBOXFG], jwin_pal[jcBOX], 0, 0, 0, 0, (void *) misccolor_tabs, NULL, (void *)misccolors_dlg },
19532 //4
19533 12 { jwin_text_proc, 215-25-12-15, 76-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Text:", NULL, NULL },
19534 12 { jwin_text_proc, 215-25-12-15, 94-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Caption:", NULL, NULL },
19535 12 { jwin_text_proc, 215-25-12-15, 112-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Overworld Minmap:", NULL, NULL },
19536 12 { jwin_text_proc, 215-25-12-15, 130-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Minimap Background:", NULL, NULL },
19537 12 { jwin_text_proc, 215-25-12-15, 148-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Minimap Foreground 1:", NULL, NULL },
19538 12 { jwin_text_proc, 215-25-12-15, 76-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Minimap Foreground 2:", NULL, NULL },
19539 12 { jwin_text_proc, 215-25-12-15, 94-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "BS Minimap Dark:", NULL, NULL },
19540 12 { jwin_text_proc, 215-25-12-15, 112-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "BS Minimap Goal:", NULL, NULL },
19541 12 { jwin_text_proc, 215-25-12-15, 130-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Compass Mark (Light):", NULL, NULL },
19542 12 { jwin_text_proc, 215-25-12-15, 148-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Compass Mark (Dark):", NULL, NULL },
19543 12 { jwin_text_proc, 215-25-12-15, 76-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Subscreen Background:", NULL, NULL },
19544 12 { jwin_text_proc, 215-25-12-15, 94-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Subscreen Shadow:", NULL, NULL },
19545 12 { jwin_text_proc, 215-25-12-15, 112-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Triforce Frame:", NULL, NULL },
19546 12 { jwin_text_proc, 215-25-12-15, 130-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Big Map Background:", NULL, NULL },
19547 12 { jwin_text_proc, 215-25-12-15, 148-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Big Map Foreground:", NULL, NULL },
19548 12 { jwin_text_proc, 215-25-12-15, 76-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Hero's Position:", NULL, NULL },
19549
19550 //20
19551 12 { d_misccolors_hexedit_proc, 294-25+14+2, 76-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)0, },
19552 12 { d_misccolors_hexedit_proc, 294-25+14+2, 94-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)1, },
19553 12 { d_misccolors_hexedit_proc, 294-25+14+2, 112-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)2, },
19554 12 { d_misccolors_hexedit_proc, 294-25+14+2, 130-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)3, },
19555 12 { d_misccolors_hexedit_proc, 294-25+14+2, 148-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)4, },
19556 12 { d_misccolors_hexedit_proc, 294-25+14+2, 76-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)5, },
19557 12 { d_misccolors_hexedit_proc, 294-25+14+2, 94-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)6, },
19558 12 { d_misccolors_hexedit_proc, 294-25+14+2, 112-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)7, },
19559 12 { d_misccolors_hexedit_proc, 294-25+14+2, 130-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)8, },
19560 12 { d_misccolors_hexedit_proc, 294-25+14+2, 148-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)9, },
19561 12 { d_misccolors_hexedit_proc, 294-25+14+2, 76-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)10, },
19562 12 { d_misccolors_hexedit_proc, 294-25+14+2, 94-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)11, },
19563 12 { d_misccolors_hexedit_proc, 294-25+14+2, 112-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)12, },
19564 12 { d_misccolors_hexedit_proc, 294-25+14+2, 130-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)13, },
19565 12 { d_misccolors_hexedit_proc, 294-25+14+2, 148-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)14, },
19566 12 { d_misccolors_hexedit_proc, 294-25+14+2, 76-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)15, },
19567
19568 //36
19569 12 { jwin_text_proc, 283-25+14+2, 76-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
19570 12 { jwin_text_proc, 283-25+14+2, 94-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
19571 12 { jwin_text_proc, 283-25+14+2, 112-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
19572 12 { jwin_text_proc, 283-25+14+2, 130-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
19573 12 { jwin_text_proc, 283-25+14+2, 148-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
19574 12 { jwin_text_proc, 283-25+14+2, 76-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
19575 12 { jwin_text_proc, 283-25+14+2, 94-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
19576 12 { jwin_text_proc, 283-25+14+2, 112-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
19577 12 { jwin_text_proc, 283-25+14+2, 130-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
19578 12 { jwin_text_proc, 283-25+14+2, 148-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
19579 12 { jwin_text_proc, 283-25+14+2, 76-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
19580 12 { jwin_text_proc, 283-25+14+2, 94-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
19581 12 { jwin_text_proc, 283-25+14+2, 112-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
19582 12 { jwin_text_proc, 283-25+14+2, 130-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
19583 12 { jwin_text_proc, 283-25+14+2, 148-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
19584 12 { jwin_text_proc, 283-25+14+2, 76-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
19585
19586 //52
19587 12 { jwin_button_proc, 90, 190-20, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
19588 12 { jwin_button_proc, 170, 190-20, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
19589 12 { jwin_text_proc, 215-25-12-15, 94-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Message Text:", NULL, NULL },
19590 12 { d_misccolors_hexedit_proc, 294-25+14+2, 94-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)35, },
19591 12 { jwin_text_proc, 283-25+14+2, 94-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
19592 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
19593 };
19594
19595 int32_t d_misccolors_tab_proc(int32_t msg,DIALOG *d,int32_t c)
19596 {
19597
19598 switch(msg)
19599 {
19600 case MSG_WANTFOCUS:
19601 return D_WANTFOCUS;
19602 break;
19603 }
19604
19605 return jwin_tab_proc(msg,d,c);
19606 }
19607
19608
19609 int32_t d_misccolors_proc(int32_t msg,DIALOG *d,int32_t c)
19610 {
19611 //these are here to bypass compiler warnings about unused arguments
19612 c=c;
19613 int32_t mul=12;
19614
19615 switch(msg)
19616 {
19617 case MSG_CLICK:
19618 if(hexclicked!=-1)
19619 {
19620 int32_t color_col=vbound(((gui_mouse_x()-d->x-8)/mul),0,15);
19621 int32_t color_row=vbound(((gui_mouse_y()-d->y-10)/mul),0,11);
19622 sprintf((char*)misccolors_dlg[hexclicked].dp,"%X%X",color_row,color_col);
19623 object_message(misccolors_dlg+hexclicked,MSG_DRAW,0);
19624 }
19625
19626 break;
19627
19628 case MSG_DRAW:
19629 for(int32_t i=0; i<10; i++)
19630 {
19631 textprintf_centre_ex(screen,font,d->x+8+4+(i*mul),d->y,jwin_pal[jcBOXFG],jwin_pal[jcBOX], "%d", i);
19632 }
19633
19634 for(int32_t i=0; i<6; i++)
19635 {
19636 textprintf_centre_ex(screen,font,d->x+8+4+((10+i)*mul),d->y,jwin_pal[jcBOXFG],jwin_pal[jcBOX], "%c", i+'A');
19637 }
19638
19639 for(int32_t i=0; i<10; i++)
19640 {
19641 textprintf_right_ex(screen,font,d->x+6,d->y+(i*mul)+10,jwin_pal[jcBOXFG],jwin_pal[jcBOX], "%d", i);
19642 }
19643
19644 for(int32_t i=0; i<2; i++)
19645 {
19646 textprintf_right_ex(screen,font,d->x+6,d->y+((i+10)*mul)+10,jwin_pal[jcBOXFG],jwin_pal[jcBOX], "%c", i+'A');
19647 }
19648
19649 jwin_draw_frame(screen,d->x+6,d->y+8,int32_t(132*1.5)-2,int32_t(100*1.5)-2,FR_DEEP);
19650
19651 for(int32_t i=0; i<192; i++)
19652 {
19653 int32_t px2 = d->x+int32_t(((i&15)<<3)*1.5)+8;
19654 int32_t py2 = d->y+int32_t(((i>>4)<<3)*1.5)+8+2;
19655 rectfill(screen,px2,py2,px2+(mul-1),py2+(mul-1),i);
19656 }
19657
19658 break;
19659 }
19660
19661 return D_O_K;
19662 }
19663
19664
19665 int32_t onMiscColors()
19666 {
19667 char buf[17][3];
19668 byte *si = &(QMisc.colors.text);
19669 misccolors_dlg[0].dp2=get_zc_font(font_lfont);
19670
19671 for(int32_t i=0; i<16; i++)
19672 {
19673 sprintf(buf[i],"%02X",*(si++));
19674 sprintf(buf[16], "%02X", QMisc.colors.msgtext);
19675 misccolors_dlg[i+20].dp = buf[i];
19676 misccolors_dlg[55].dp = buf[16];
19677 }
19678
19679 large_dialog(misccolors_dlg);
19680
19681 if(do_zqdialog(misccolors_dlg,0)==52)
19682 {
19683 mark_save_dirty();
19684 si = &(QMisc.colors.text);
19685
19686 for(int32_t i=0; i<16; i++)
19687 {
19688 *si = zc_xtoi(buf[i]);
19689 ++si;
19690 }
19691
19692 QMisc.colors.msgtext = zc_xtoi(buf[16]);
19693 }
19694
19695 return D_O_K;
19696 }
19697
19698 // **** Palette cycling ****
19699
19700 static int32_t palclk[3];
19701 static int32_t palpos[3];
19702
19703 22 void reset_pal_cycling()
19704 {
19705
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 22 times.
88 for(int32_t i=0; i<3; i++)
19706 66 palclk[i]=palpos[i]=0;
19707 22 }
19708
19709 void cycle_palette()
19710 {
19711 if(!get_qr(qr_FADE))
19712 return;
19713
19714 int32_t level = Map.CurrScr()->color;
19715 bool refreshpal = false;
19716
19717 for(int32_t i=0; i<3; i++)
19718 {
19719 palcycle c = QMisc.cycles[level][i];
19720
19721 if(c.count&0xF0)
19722 {
19723 if(++palclk[i] >= c.speed)
19724 {
19725 palclk[i]=0;
19726
19727 if(++palpos[i] >= (c.count>>4))
19728 palpos[i]=0;
19729
19730 byte *si = colordata + CSET(level*pdLEVEL+poFADE1+1+palpos[i])*3;
19731
19732 si += (c.first&15)*3;
19733
19734 for(int32_t col=c.first&15; col<=(c.count&15); col++)
19735 {
19736 RAMpal[CSET(c.first>>4)+col] = _RGB(si);
19737 si+=3;
19738 }
19739
19740 refreshpal = true;
19741 }
19742 }
19743 }
19744
19745 if(refreshpal)
19746 {
19747 rebuild_trans_table();
19748 zc_set_palette_range(RAMpal,0,192,false);
19749 }
19750 }
19751
19752
19753 static void doHelp()
19754 {
19755 do_box_edit(helpstr, "ZQuest Help", true, true);
19756 }
19757
19758 int32_t onHelp()
19759 {
19760 restore_mouse();
19761 doHelp();
19762 return D_O_K;
19763 }
19764
19765 void doZstringshelp()
19766 {
19767 do_box_edit(zstringshelpstr, "ZStrings Help", true, true);
19768 }
19769
19770 int32_t onZstringshelp()
19771 {
19772 restore_mouse();
19773 doZstringshelp();
19774 return D_O_K;
19775 }
19776
19777 void call_layer_dialog(int map, int scr);
19778 int32_t onLayers()
19779 {
19780 call_layer_dialog(Map.getCurrMap(), Map.getCurrScr());
19781 if (CurrentLayer > 0 && Map.CurrScr()->layermap[CurrentLayer-1] == 0)
19782 CurrentLayer = 0;
19783 return D_O_K;
19784 }
19785
19786 void fps_callback()
19787 {
19788 lastfps=framecnt;
19789 framecnt=0;
19790 }
19791
19792 END_OF_FUNCTION(fps_callback)
19793
19794 //uint32_t col_diff[3*128];
19795 /*
19796 void bestfit_init(void)
19797 {
19798 int32_t i;
19799
19800 for (i=1; i<64; i++)
19801
19802 {
19803 int32_t k = i * i;
19804 col_diff[0 +i] = col_diff[0 +128-i] = k * (59 * 59);
19805 col_diff[128+i] = col_diff[128+128-i] = k * (30 * 30);
19806 col_diff[256+i] = col_diff[256+128-i] = k * (11 * 11);
19807 }
19808 }
19809 */
19810 void create_rgb_table2(RGB_MAP *table, AL_CONST PALETTE pal_8bit, void (*callback)(int32_t pos))
19811 {
19812 #define UNUSED 65535
19813 #define LAST 65532
19814
19815 // Allegro has been modified to use an 8 bit palette, but this method and RGB_MAP still use 6 bit.
19816 PALETTE pal;
19817 for (int i = 0; i < 256; i++)
19818 {
19819 pal[i] = pal_8bit[i];
19820 pal[i].r /= 4;
19821 pal[i].g /= 4;
19822 pal[i].b /= 4;
19823 }
19824
19825 /* macro add adds to single linked list */
19826 #define add(i) (next[(i)] == UNUSED ? (next[(i)] = LAST, \
19827 (first != LAST ? (next[last] = (i)) : (first = (i))), \
19828 (last = (i))) : 0)
19829
19830 /* same but w/o checking for first element */
19831 #define add1(i) (next[(i)] == UNUSED ? (next[(i)] = LAST, \
19832 next[last] = (i), \
19833 (last = (i))) : 0)
19834 /* calculates distance between two colors */
19835 #define dist(a1, a2, a3, b1, b2, b3) \
19836 (col_diff[ ((a2) - (b2)) & 0x7F] + \
19837 (col_diff + 128)[((a1) - (b1)) & 0x7F] + \
19838 (col_diff + 256)[((a3) - (b3)) & 0x7F])
19839
19840 /* converts r,g,b to position in array and back */
19841 #define pos(r, g, b) \
19842 (((r) / 2) * 32 * 32 + ((g) / 2) * 32 + ((b) / 2))
19843
19844 #define depos(pal, r, g, b) \
19845 ((b) = ((pal) & 31) * 2, \
19846 (g) = (((pal) >> 5) & 31) * 2, \
19847 (r) = (((pal) >> 10) & 31) * 2)
19848
19849 /* is current color better than pal1? */
19850 #define better(r1, g1, b1, pal1) \
19851 (((int32_t)dist((r1), (g1), (b1), \
19852 (pal1).r, (pal1).g, (pal1).b)) > (int32_t)dist2)
19853
19854 /* checking of position */
19855 #define dopos(rp, gp, bp, ts) \
19856 if ((rp > -1 || r > 0) && (rp < 1 || r < 61) && \
19857 (gp > -1 || g > 0) && (gp < 1 || g < 61) && \
19858 (bp > -1 || b > 0) && (bp < 1 || b < 61)) \
19859 { \
19860 i = first + rp * 32 * 32 + gp * 32 + bp; \
19861 if (!data[i]) \
19862 { \
19863 data[i] = val; \
19864 add1(i); \
19865 } \
19866 else if ((ts) && (data[i] != val)) \
19867 { \
19868 dist2 = (rp ? (col_diff+128)[(r+2*rp-pal[val].r) & 0x7F] : r2) + \
19869 (gp ? (col_diff )[(g+2*gp-pal[val].g) & 0x7F] : g2) + \
19870 (bp ? (col_diff+256)[(b+2*bp-pal[val].b) & 0x7F] : b2); \
19871 if (better((r+2*rp), (g+2*gp), (b+2*bp), pal[data[i]])) \
19872 { \
19873 data[i] = val; \
19874 add1(i); \
19875 } \
19876 } \
19877 }
19878
19879 int32_t i, curr, r, g, b, val, dist2;
19880 uint32_t r2, g2, b2;
19881 uint16_t next[32*32*32];
19882 uint8_t *data;
19883 int32_t first = LAST;
19884 int32_t last = LAST;
19885 int32_t count = 0;
19886 int32_t cbcount = 0;
19887
19888 #define AVERAGE_COUNT 18000
19889
19890 if(col_diff[1] == 0)
19891 bestfit_init();
19892
19893 memset(next, 255, sizeof(next));
19894 memset(table->data, 0, sizeof(char)*32*32*32);
19895
19896
19897 data = (uint8_t *)table->data;
19898
19899 /* add starting seeds for floodfill */
19900 for(i=1; i<PAL_SIZE; i++)
19901 {
19902 curr = pos(pal[i].r, pal[i].g, pal[i].b);
19903
19904 if(next[curr] == UNUSED)
19905 {
19906 data[curr] = i;
19907 add(curr);
19908 }
19909 }
19910
19911 /* main floodfill: two versions of loop for faster growing in blue axis */
19912 // while (first != LAST) {
19913 while(first < LAST)
19914 {
19915 depos(first, r, g, b);
19916
19917 /* calculate distance of current color */
19918 val = data[first];
19919 r2 = (col_diff+128)[((pal[val].r)-(r)) & 0x7F];
19920 g2 = (col_diff)[((pal[val].g)-(g)) & 0x7F];
19921 b2 = (col_diff+256)[((pal[val].b)-(b)) & 0x7F];
19922
19923 /* try to grow to all directions */
19924 #ifdef _MSC_VER
19925 #pragma warning(disable:4127)
19926 #endif
19927 dopos(0, 0, 1, 1);
19928 dopos(0, 0,-1, 1);
19929 dopos(1, 0, 0, 1);
19930 dopos(-1, 0, 0, 1);
19931 dopos(0, 1, 0, 1);
19932 dopos(0,-1, 0, 1);
19933 #ifdef _MSC_VER
19934 #pragma warning(default:4127)
19935 #endif
19936
19937 /* faster growing of blue direction */
19938 if((b > 0) && (data[first-1] == val))
19939 {
19940 b -= 2;
19941 first--;
19942 b2 = (col_diff+256)[((pal[val].b)-(b)) & 0x7F];
19943
19944 #ifdef _MSC_VER
19945 #pragma warning(disable:4127)
19946 #endif
19947 dopos(-1, 0, 0, 0);
19948 dopos(1, 0, 0, 0);
19949 dopos(0,-1, 0, 0);
19950 dopos(0, 1, 0, 0);
19951 #ifdef _MSC_VER
19952 #pragma warning(default:4127)
19953 #endif
19954
19955 first++;
19956 }
19957
19958 /* get next from list */
19959 i = first;
19960 first = next[first];
19961 next[i] = UNUSED;
19962
19963 /* second version of loop */
19964 // if (first != LAST) {
19965 if(first < LAST)
19966 {
19967
19968 depos(first, r, g, b);
19969
19970 val = data[first];
19971 r2 = (col_diff+128)[((pal[val].r)-(r)) & 0x7F];
19972 g2 = (col_diff)[((pal[val].g)-(g)) & 0x7F];
19973 b2 = (col_diff+256)[((pal[val].b)-(b)) & 0x7F];
19974
19975 #ifdef _MSC_VER
19976 #pragma warning(disable:4127)
19977 #endif
19978 dopos(0, 0, 1, 1);
19979 dopos(0, 0,-1, 1);
19980 dopos(1, 0, 0, 1);
19981 dopos(-1, 0, 0, 1);
19982 dopos(0, 1, 0, 1);
19983 dopos(0,-1, 0, 1);
19984 #ifdef _MSC_VER
19985 #pragma warning(default:4127)
19986 #endif
19987
19988 if((b < 61) && (data[first + 1] == val))
19989 {
19990 b += 2;
19991 first++;
19992 b2 = (col_diff+256)[((pal[val].b)-(b)) & 0x7f];
19993 #ifdef _MSC_VER
19994 #pragma warning(disable:4127)
19995 #endif
19996 dopos(-1, 0, 0, 0);
19997 dopos(1, 0, 0, 0);
19998 dopos(0,-1, 0, 0);
19999 dopos(0, 1, 0, 0);
20000 #ifdef _MSC_VER
20001 #pragma warning(default:4127)
20002 #endif
20003
20004 first--;
20005 }
20006
20007 i = first;
20008 first = next[first];
20009 next[i] = UNUSED;
20010 }
20011
20012 count++;
20013
20014 if(count == (cbcount+1)*AVERAGE_COUNT/256)
20015 {
20016 if(cbcount < 256)
20017 {
20018 if(callback)
20019 callback(cbcount);
20020
20021 cbcount++;
20022 }
20023 }
20024
20025 }
20026
20027 /* only the transparent (pink) color can be mapped to index 0 */
20028 if((pal[0].r == 63) && (pal[0].g == 0) && (pal[0].b == 63))
20029 table->data[31][0][31] = 0;
20030
20031 if(callback)
20032 while(cbcount < 256)
20033 callback(cbcount++);
20034 }
20035
20036 11 void rebuild_trans_table()
20037 {
20038 11 refresh_rgb_tables();
20039 11 zq_rgb_table = rgb_table;
20040 11 }
20041
20042 int32_t isFullScreen()
20043 {
20044 return !is_windowed_mode();
20045 }
20046
20047 void hit_close_button()
20048 {
20049 close_button_quit=true;
20050 return;
20051 }
20052
20053 extern bool dirty_screen;
20054
20055 void anim_hw_screen()
20056 {
20057 ++cpoolbrush_index;
20058
20059 if(prv_mode)
20060 {
20061 if(Map.get_prvtime())
20062 {
20063 Map.set_prvtime(Map.get_prvtime()-1);
20064
20065 if(!Map.get_prvtime())
20066 {
20067 prv_warp=1;
20068 }
20069 }
20070 }
20071 if(AnimationOn)
20072 {
20073 animate_combos();
20074 update_freeform_combos();
20075 }
20076
20077 if(CycleOn)
20078 cycle_palette();
20079
20080 animate_coords();
20081 update_hw_screen();
20082 }
20083
20084 void custom_vsync()
20085 {
20086 anim_hw_screen();
20087 }
20088
20089 void switch_out()
20090 {
20091 zcmusic_pause(zcmusic, ZCM_PAUSE);
20092 zc_midi_pause();
20093 }
20094
20095 void switch_in()
20096 {
20097 if(exiting_program)
20098 return;
20099 zcmusic_pause(zcmusic, ZCM_RESUME);
20100 zc_midi_resume();
20101 }
20102
20103 void Z_eventlog(const char *format,...)
20104 {
20105 format=format; //to prevent a compiler warning
20106 }
20107
20108 int32_t get_currdmap()
20109 {
20110 return zinit.start_dmap;
20111 }
20112
20113 int32_t get_dlevel()
20114 {
20115 return DMaps[zinit.start_dmap].level;
20116 }
20117
20118 int32_t get_currscr()
20119 {
20120 return Map.getCurrScr();
20121 }
20122
20123 int32_t get_currmap()
20124 {
20125 return Map.getCurrMap();
20126 }
20127
20128 int32_t get_homescr()
20129 {
20130 return DMaps[zinit.start_dmap].cont;
20131 }
20132
20133 int get_screen_for_world_xy(int x, int y)
20134 {
20135 return -1;
20136 }
20137
20138 int current_item(int item_type, bool checkmagic, bool jinx_check, bool check_bunny)
20139 {
20140 //TODO remove as special case?? -DD
20141 if(item_type==itype_shield)
20142 {
20143 return 2;
20144 }
20145
20146 int id = current_item_id(item_type, checkmagic, jinx_check, check_bunny);
20147 return id > -1 ? itemsbuf[id].level : 0;
20148 }
20149
20150 int current_item_power(int itemtype, bool checkmagic, bool jinx_check, bool check_bunny)
20151 {
20152 if (game)
20153 {
20154 int result = current_item_id(itemtype, checkmagic, jinx_check, check_bunny);
20155 return (result<0) ? 0 : itemsbuf[result].power;
20156 }
20157 return 1;
20158 }
20159
20160 int32_t current_item_id(int32_t itemtype, bool, bool, bool)
20161 {
20162 if (game)
20163 {
20164 int32_t result = -1;
20165 int32_t highestlevel = -1;
20166
20167 for (int32_t i = 0; i < MAXITEMS; i++)
20168 {
20169 if ((zq_ignore_item_ownership || game->get_item(i)) && itemsbuf[i].type == itemtype)
20170 {
20171 if (itemsbuf[i].level >= highestlevel)
20172 {
20173 highestlevel = itemsbuf[i].level;
20174 result = i;
20175 }
20176 }
20177 }
20178 return result;
20179 }
20180 for(int32_t i=0; i<MAXITEMS; i++)
20181 {
20182 if(itemsbuf[i].type==itemtype)
20183 return i;
20184 }
20185
20186 return -1;
20187 }
20188
20189
20190 bool can_use_item(int32_t item_type, int32_t item)
20191 {
20192 //these are here to bypass compiler warnings about unused arguments
20193 item_type=item_type;
20194 item=item;
20195
20196 return true;
20197 }
20198
20199 bool has_item(int32_t item_type, int32_t it)
20200 {
20201 //these are here to bypass compiler warnings about unused arguments
20202 item_type=item_type;
20203 it=it;
20204
20205 return true;
20206 }
20207
20208 int32_t get_bmaps(int32_t si)
20209 {
20210 //these are here to bypass compiler warnings about unused arguments
20211 si=si;
20212
20213 return 255;
20214 }
20215
20216 bool no_subscreen()
20217 {
20218 return false;
20219 }
20220
20221 12 static void allocate_crap()
20222 {
20223 12 filepath=(char*)malloc(2048);
20224 12 datapath=(char*)malloc(2048);
20225 12 midipath=(char*)malloc(2048);
20226 12 imagepath=(char*)malloc(2048);
20227 12 tmusicpath=(char*)malloc(2048);
20228 12 last_timed_save=(char*)malloc(2048);
20229
20230
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!filepath || !datapath || !imagepath || !midipath || !tmusicpath || !last_timed_save)
20231 {
20232 Z_error_fatal("Error: no memory for file paths!");
20233 }
20234
20235
20236 12 customtunes = (zctune*)malloc(sizeof(zctune)*MAXCUSTOMMIDIS_ZQ);
20237 12 memset(customtunes, 0, sizeof(zctune)*MAXCUSTOMMIDIS_ZQ);
20238
20239
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
3084 for(int32_t i=0; i<MAXCUSTOMMIDIS_ZQ; ++i)
20240 {
20241 3072 customtunes[i].data=NULL;
20242 3072 }
20243
20244
2/2
✓ Branch 0 taken 3024 times.
✓ Branch 1 taken 12 times.
3036 for(int32_t i=0; i<MAXCUSTOMTUNES; i++)
20245 {
20246 3024 midi_string[i+4]=customtunes[i].title;
20247 3024 screen_midi_string[i+5]=customtunes[i].title;
20248 3024 }
20249
20250
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
3084 for(int32_t i=0; i<WAV_COUNT; i++)
20251 {
20252
1/4
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3072 if(sfx_string[i]!=NULL) delete sfx_string[i];
20253 3072 customsfxdata[i].data=NULL;
20254 3072 sfx_string[i] = new char[36];
20255 3072 memset(sfx_string[i], 0, 36);
20256 3072 }
20257
20258
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
3084 for(int32_t i=0; i<MAXWPNS; i++)
20259 {
20260
1/4
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3072 if(weapon_string[i]!=NULL) delete weapon_string[i];
20261 3072 weapon_string[i] = new char[64];
20262 3072 memset(weapon_string[i], 0, 64);
20263 3072 }
20264
20265
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
3084 for(int32_t i=0; i<MAXITEMS; i++)
20266 {
20267
1/4
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3072 if(item_string[i]!=NULL) delete item_string[i];
20268 3072 item_string[i] = new char[64];
20269 3072 memset(item_string[i], 0, 64);
20270 3072 }
20271
20272
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 12 times.
6156 for(int32_t i=0; i<eMAXGUYS; i++)
20273 {
20274
1/4
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6144 if(guy_string[i]!=NULL) delete guy_string[i];
20275 6144 guy_string[i] = new char[64];
20276 6144 memset(guy_string[i], 0, 64);
20277 6144 }
20278
20279
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 12 times.
6156 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
20280 {
20281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6144 times.
6144 delete ffscripts[i];
20282
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 ffscripts[i] = new script_data(ScriptType::FFC, i);
20283 6144 }
20284
20285
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
3084 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
20286 {
20287
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 delete itemscripts[i];
20288
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 itemscripts[i] = new script_data(ScriptType::Item, i);
20289 3072 }
20290
20291
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
3084 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
20292 {
20293
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 delete guyscripts[i];
20294
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 guyscripts[i] = new script_data(ScriptType::NPC, i);
20295 3072 }
20296
20297
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
3084 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
20298 {
20299
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 delete screenscripts[i];
20300
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 screenscripts[i] = new script_data(ScriptType::Screen, i);
20301 3072 }
20302
20303
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 12 times.
108 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
20304 {
20305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 delete globalscripts[i];
20306
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 globalscripts[i] = new script_data(ScriptType::Global, i);
20307 96 }
20308
20309
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 12 times.
72 for(int32_t i=0; i<NUMSCRIPTHERO; i++)
20310 {
20311
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 delete playerscripts[i];
20312
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 playerscripts[i] = new script_data(ScriptType::Hero, i);
20313 60 }
20314
20315
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
3084 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
20316 {
20317
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 delete lwpnscripts[i];
20318
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 lwpnscripts[i] = new script_data(ScriptType::Lwpn, i);
20319 3072 }
20320
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
3084 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
20321 {
20322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3072 times.
3072 delete ewpnscripts[i];
20323
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 ewpnscripts[i] = new script_data(ScriptType::Ewpn, i);
20324 3072 }
20325
20326
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
3084 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
20327 {
20328
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 delete dmapscripts[i];
20329
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 dmapscripts[i] = new script_data(ScriptType::DMap, i);
20330 3072 }
20331
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
3084 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
20332 {
20333
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 delete itemspritescripts[i];
20334
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 itemspritescripts[i] = new script_data(ScriptType::ItemSprite, i);
20335 3072 }
20336
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 12 times.
6156 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
20337 {
20338
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 delete comboscripts[i];
20339
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 comboscripts[i] = new script_data(ScriptType::Combo, i);
20340 6144 }
20341
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 12 times.
6156 for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++)
20342 {
20343
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 delete genericscripts[i];
20344
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 genericscripts[i] = new script_data(ScriptType::Generic, i);
20345 6144 }
20346
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
3084 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN; i++)
20347 {
20348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3072 times.
3072 delete subscreenscripts[i];
20349
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 subscreenscripts[i] = new script_data(ScriptType::EngineSubscreen, i);
20350 3072 }
20351 12 }
20352
20353 static void handle_sentry_tags()
20354 {
20355 static bool sentry_first_time = true;
20356
20357 static MapCursor sentry_last_map_cursor;
20358 if (Map.getCursor() != sentry_last_map_cursor || sentry_first_time)
20359 {
20360 sentry_last_map_cursor = Map.getCursor();
20361 zapp_reporting_set_tag("cursor.map", sentry_last_map_cursor.map);
20362 zapp_reporting_set_tag("cursor.screen", sentry_last_map_cursor.screen);
20363 zapp_reporting_set_tag("cursor.viewscr", sentry_last_map_cursor.viewscr);
20364 zapp_reporting_set_tag("cursor.size", sentry_last_map_cursor.size);
20365 }
20366
20367 static bool sentry_last_is_compact;
20368 if (is_compact != sentry_last_is_compact || sentry_first_time)
20369 {
20370 sentry_last_is_compact = is_compact;
20371 zapp_reporting_set_tag("compact", sentry_last_is_compact);
20372 }
20373
20374 sentry_first_time = false;
20375 }
20376
20377 int32_t Awpn=-1, Bwpn=-1, Xwpn = -1, Ywpn = -1;
20378 84 sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations, portals;
20379 int32_t exittimer = 10000, exittimer2 = 100;
20380
20381 template <typename ...Params>
20382 [[noreturn]] void FatalConsole(const char *format, Params&&... params)
20383 {
20384 FFCore.ZScriptConsole(CConsoleLoggerEx::COLOR_RED|CConsoleLoggerEx::COLOR_INTENSITY|CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"");
20385 Z_error_fatal(format, std::forward<Params>(params)...);
20386 }
20387
20388 5 static BITMAP* load_asset_bmp(const char* path)
20389 {
20390 5 BITMAP* bmp = load_bmp(path, nullptr);
20391
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if (!bmp)
20392 Z_error_fatal("Failed to load required asset: %s\n", path);
20393 5 return bmp;
20394 }
20395
20396 1 static void load_asset_pal(PALETTE pal, const char* path)
20397 {
20398 1 BITMAP* bmp = load_bmp(path, pal);
20399
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (!bmp)
20400 Z_error_fatal("Failed to load required asset: %s\n", path);
20401 1 }
20402
20403 1 static MIDI* load_asset_midi(const char* path)
20404 {
20405 1 MIDI* midi = load_midi(path);
20406
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (!midi)
20407 Z_error_fatal("Failed to load required asset: %s\n", path);
20408 1 return midi;
20409 }
20410
20411 BITMAP* asset_icons_bmp;
20412 BITMAP* asset_engravings_bmp;
20413 BITMAP* asset_mouse_bmp;
20414 BITMAP* asset_select_bmp;
20415 BITMAP* asset_arrows_bmp;
20416 MIDI* asset_tunes_midi;
20417 PALETTE asset_pal;
20418
20419 1 static void load_assets()
20420 {
20421 1 asset_icons_bmp = load_asset_bmp("assets/editor/icons.bmp");
20422 1 asset_engravings_bmp = load_asset_bmp("assets/editor/engravings.bmp");
20423 1 asset_mouse_bmp = load_asset_bmp("assets/editor/mouse.bmp");
20424 1 asset_select_bmp = load_asset_bmp("assets/editor/select.bmp");
20425 1 asset_arrows_bmp = load_asset_bmp("assets/editor/arrows.bmp");
20426 1 asset_tunes_midi = load_asset_midi("assets/editor/tunes.mid");
20427 1 load_asset_pal(asset_pal, "assets/editor/pal.bmp");
20428 1 }
20429
20430 static bool application_has_loaded;
20431
20432 void do_dev_qrs_zscript_command(string const& fname);
20433
20434 1 int32_t main(int32_t argc,char **argv)
20435 {
20436
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (used_switch(argc, argv, "-test-zc"))
20437 1 set_headless_mode();
20438
20439 1 zalleg_setup_allegro(App::zquest, argc, argv);
20440 1 allocate_crap();
20441
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 set_should_zprint_cb([]() {
20442 return get_qr(qr_SCRIPTERRLOG) || DEVLEVEL > 0;
20443 });
20444
20445 1 Z_title("ZQuest Classic Editor, %s", getVersionString());
20446
20447
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!get_qst_buffers())
20448 {
20449 Z_error_fatal("Error");
20450 }
20451
20452 1 undocombobuf.clear();
20453 1 undocombobuf.resize(MAXCOMBOS);
20454
20455
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if((newundotilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
20456 {
20457 Z_error_fatal("Error: no memory for tile undo buffer!");
20458 }
20459
20460 1 memset(newundotilebuf, 0, NEWMAXTILES*sizeof(tiledata));
20461 1 newtilebuf = (tiledata*)malloc(NEWMAXTILES*sizeof(tiledata));
20462
20463
2/2
✓ Branch 0 taken 2574000 times.
✓ Branch 1 taken 1 times.
2574001 for(int32_t j=0; j<NEWMAXTILES; j++)
20464 2574000 newtilebuf[j].data=NULL;
20465
20466 1 zc_srand(time(0));
20467
20468 1 zeditor_handle_commands();
20469
20470 1 three_finger_flag=false;
20471
20472 #ifndef __EMSCRIPTEN__
20473
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(zc_get_config("zquest","open_debug_console",0))
20474 initConsole();
20475 #endif
20476
20477 LOCK_VARIABLE(lastfps);
20478
20479 LOCK_VARIABLE(framecnt);
20480 LOCK_FUNCTION(fps_callback);
20481
20482
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
20483 {
20484 Z_error_fatal("couldn't allocate timer");
20485 }
20486
20487
20488 LOCK_VARIABLE(dclick_status);
20489 LOCK_VARIABLE(dclick_time);
20490 1 lock_dclick_function();
20491 1 install_int(dclick_check, 20);
20492
20493 1 set_gfx_mode(GFX_TEXT,80,50,0,0);
20494
20495 1 load_assets();
20496
20497 1 Z_message("OK\n");
20498
20499
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 helpstr = util::read_text_file("docs/zquest.txt");
20500
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 zstringshelpstr = util::read_text_file("docs/zstrings.txt");
20501
20502 // loading data files...
20503
20504 1 filepath[0]=temppath[0]=0;
20505
20506 1 const char *default_path="";
20507
20508 1 strcpy(datapath,zc_get_config("zquest",data_path_name,default_path));
20509 1 strcpy(midipath,zc_get_config("zquest",midi_path_name,default_path));
20510 1 strcpy(imagepath,zc_get_config("zquest",image_path_name,default_path));
20511 1 strcpy(tmusicpath,zc_get_config("zquest",tmusic_path_name,default_path));
20512 1 chop_path(datapath);
20513 1 chop_path(midipath);
20514 1 chop_path(imagepath);
20515 1 chop_path(tmusicpath);
20516
20517 1 DisableLPalShortcuts = zc_get_config("zquest","dis_lpal_shortcut",1);
20518 1 DisableCompileConsole = zc_get_config("zquest","internal_compile_console",0);
20519 1 MouseScroll = zc_get_config("zquest","mouse_scroll",0);
20520 1 MMapCursorStyle = zc_get_config("zquest","cursorblink_style",1);
20521 1 LayerDitherBG = zc_get_config("zquest", "layer_dither_bg", -1);
20522 1 LayerDitherSz = zc_get_config("zquest", "layer_dither_sz", 3);
20523 1 InvalidBG = zc_get_config("zquest", "invalid_bg", 0);
20524 1 TileProtection = zc_get_config("zquest","tile_protection",1);
20525 1 ComboProtection = zc_get_config("zquest","combo_protection",TileProtection);
20526 1 ShowGrid = zc_get_config("zquest","show_grid",0);
20527 1 ShowCurScreenOutline = zc_get_config("zquest","show_current_screen_outline",1);
20528 1 ShowScreenGrid = zc_get_config("zquest","show_screen_grid",0);
20529 1 ShowRegionGrid = zc_get_config("zquest","show_region_grid",1);
20530 1 HighQualityScreenRendering = zc_get_config("zquest","high_quality_screen_rendering",1);
20531 1 GridColor = zc_get_config("zquest","grid_color",15);
20532 1 CmbCursorCol = zc_get_config("zquest","combo_cursor_color",15);
20533 1 TilePgCursorCol = zc_get_config("zquest","tpage_cursor_color",15);
20534 1 CmbPgCursorCol = zc_get_config("zquest","cpage_cursor_color",15);
20535 1 TTipHLCol = zc_get_config("zquest","ttip_hl_color",13);
20536 1 CheckerCol1 = zc_get_config("zquest","checker_color_1",7);
20537 1 CheckerCol2 = zc_get_config("zquest","checker_color_2",8);
20538 1 SnapshotFormat = zc_get_config("zquest","snapshot_format",3);
20539 1 SnapshotScale = zc_get_config("zquest","snapshot_scale",2);
20540 1 SavePaths = zc_get_config("zquest","save_paths",1);
20541 1 CycleOn = zc_get_config("zquest","cycle_on",1);
20542 1 ShowFPS = zc_get_config("zquest","showfps",0)!=0;
20543 1 SaveDragResize = zc_get_config("zquest","save_drag_resize",0)!=0;
20544 1 DragAspect = zc_get_config("zquest","drag_aspect",0)!=0;
20545 1 SaveWinPos = zc_get_config("zquest","save_window_position",0)!=0;
20546 1 ComboBrush = zc_get_config("zquest","combo_brush",0);
20547 1 FloatBrush = zc_get_config("zquest","float_brush",0);
20548 1 AutoBrush = zc_get_config("zquest","autobrush",1);
20549 1 LinkedScroll = zc_get_config("zquest","linked_comboscroll",0);
20550 1 allowHideMouse = zc_get_config("ZQ_GUI","allowHideMouse",0);
20551 1 ShowFavoriteComboModes = zc_get_config("ZQ_GUI","show_fav_combo_modes",1);
20552 1 NoHighlightLayer0 = zc_get_config("zquest","no_highlight_layer0",0);
20553 1 RulesetDialog = zc_get_config("zquest","rulesetdialog",1);
20554 1 EnableTooltips = zc_get_config("zquest","enable_tooltips",1);
20555 1 TooltipsHighlight = zc_get_config("zquest","ttip_highlight",1);
20556 1 tooltip_maxtimer = vbound(zc_get_config("zquest","ttip_timer",30),0,60*60);
20557 1 ShowFFScripts = zc_get_config("zquest","showffscripts",1);
20558 1 ShowSquares = zc_get_config("zquest","showsquares",1);
20559 1 ShowFFCs = zc_get_config("zquest","showffcs",0);
20560 1 ShowInfo = zc_get_config("zquest","showinfo",1);
20561 1 skipLayerWarning = zc_get_config("zquest","skip_layer_warning",0);
20562 1 numericalFlags = zc_get_config("zquest","numerical_flags",0);
20563 1 ViewLayer2BG = zc_get_config("zquest","layer2_bg",0);
20564 1 ViewLayer3BG = zc_get_config("zquest","layer3_bg",0);
20565 1 ActiveLayerHighlight = zc_get_config("zquest","hl_active_lyr",0);
20566 1 DragCenterOfSquares = zc_get_config("zquest","drag_squares_from_center",0);
20567 1 SmartFFCPlacement = zc_get_config("zquest","smart_ffc_placement",0);
20568
20569 1 OpenLastQuest = zc_get_config("zquest","open_last_quest",0);
20570 1 ShowMisalignments = zc_get_config("zquest","show_misalignments",0);
20571 1 AnimationOn = zc_get_config("zquest","animation_on",1);
20572 1 AutoBackupRetention = zc_get_config("zquest","auto_backup_retention",2);
20573 1 AutoSaveInterval = zc_get_config("zquest","auto_save_interval",6);
20574 1 AutoSaveRetention = zc_get_config("zquest","auto_save_retention",2);
20575 1 UncompressedAutoSaves = zc_get_config("zquest","uncompressed_auto_saves",1);
20576 1 OverwriteProtection = zc_get_config("zquest","overwrite_prevention",0)!=0;
20577 1 ImportMapBias = zc_get_config("zquest","import_map_bias",0);
20578
20579 1 KeyboardRepeatDelay = zc_get_config("zquest","keyboard_repeat_delay",300);
20580 1 KeyboardRepeatRate = zc_get_config("zquest","keyboard_repeat_rate",80);
20581
20582 // Frameskip = zc_get_config("zquest","frameskip",0); //todo: this is not actually supported yet.
20583 1 RequestedFPS = zc_get_config("zquest","fps",60);
20584
20585 // Autofill for Combo Page, Tile Page
20586 1 PreFillTileEditorPage = zc_get_config("zquest","PreFillTileEditorPage",0);
20587 1 PreFillComboEditorPage = zc_get_config("zquest","PreFillComboEditorPage",0);
20588
20589 1 pixeldb = zc_get_config("ZQ_GUI","bottom_8_pixels",0);
20590 1 infobg = zc_get_config("ZQ_GUI","info_text_bg",0);
20591
20592 1 large_merged_combopane = zc_get_config("ZQ_GUI","merge_cpane_large",0);
20593 1 compact_merged_combopane = zc_get_config("ZQ_GUI","merge_cpane_compact",1);
20594
20595 1 compact_square_panels = zc_get_config("ZQ_GUI","square_panels_compact",0);
20596
20597 1 large_zoomed_fav = zc_get_config("ZQ_GUI","zoom_fav_large",0);
20598 1 compact_zoomed_fav = zc_get_config("ZQ_GUI","zoom_fav_compact",1);
20599 1 large_zoomed_cmd = zc_get_config("ZQ_GUI","zoom_cmd_large",1);
20600 1 compact_zoomed_cmd = zc_get_config("ZQ_GUI","zoom_cmd_compact",1);
20601
20602
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(zc_get_config("gui","disable_window_resizing",0))
20603 all_set_resize_flag(false);
20604
20605 1 load_hotkeys();
20606
20607 #ifdef _WIN32
20608 zqUseWin32Proc = zc_get_config("zquest","zq_win_proc_fix",0);
20609
20610 #endif
20611
20612
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (!render_timer_start())
20613 {
20614 Z_error_fatal("couldn't allocate timer");
20615 }
20616
20617 1 byte layermask = zc_get_config("zquest","layer_mask",0x7F);
20618 1 int32_t usefullscreen = zc_get_config("zquest","fullscreen",0);
20619 1 tempmode = (usefullscreen == 0 ? GFX_AUTODETECT_WINDOWED : GFX_AUTODETECT_FULLSCREEN);
20620
20621
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1 times.
8 for(int32_t x=0; x<7; x++)
20622 {
20623 7 LayerMaskInt[x]=get_bit(&layermask,x);
20624 7 }
20625
20626 1 DuplicateAction[0] = zc_get_config("zquest","normal_duplicate_action",2);
20627 1 DuplicateAction[1] = zc_get_config("zquest","horizontal_duplicate_action",0);
20628 1 DuplicateAction[2] = zc_get_config("zquest","vertical_duplicate_action",0);
20629 1 DuplicateAction[3] = zc_get_config("zquest","both_duplicate_action",0);
20630 1 LeechUpdate = zc_get_config("zquest","leech_update",500);
20631 1 LeechUpdateTiles = zc_get_config("zquest","leech_update_tiles",1);
20632 1 OnlyCheckNewTilesForDuplicates = zc_get_config("zquest","only_check_new_tiles_for_duplicates",0);
20633 //gui_colorset = zc_get_config("zquest","gui_colorset",0);
20634
20635 1 strcpy(last_timed_save,zc_get_config("zquest","last_timed_save",""));
20636
20637 1 midi_volume = zc_get_config("zquest", "midi", 255);
20638
20639 1 abc_patternmatch = zc_get_config("zquest", "lister_pattern_matching", 1);
20640 1 NoScreenPreview = zc_get_config("zquest", "no_preview", 0);
20641
20642 1 monochrome_console = zc_get_config("CONSOLE","monochrome_debuggers",0)?1:0;
20643
20644 1 try_recovering_missing_scripts = 0;//zc_get_config("Compiler", "try_recovering_missing_scripts",0);
20645 //We need to remove all of the zeldadx refs to the config file for zquest.
20646
20647 1 set_keyboard_rate(KeyboardRepeatDelay,KeyboardRepeatRate);
20648
20649 1 is_compact = zc_get_config("ZQ_GUI","compact_mode",1);
20650 1 mapscreenbmp = nullptr;
20651 1 brushbmp = nullptr;
20652 1 brushscreen = nullptr;
20653 1 screen2 = nullptr;
20654
20655
2/2
✓ Branch 0 taken 1260 times.
✓ Branch 1 taken 1 times.
1261 for(int32_t i=0; i<MAXFAVORITECOMBOS; ++i)
20656 {
20657 1260 favorite_combos[i]=-1;
20658 1260 }
20659 1 FavoriteComboPage = 0;
20660
20661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(used_switch(argc,argv,"-d"))
20662 {
20663 set_debug(!strcmp(zquestpwd,zc_get_config("zquest","debug_this","")));
20664 }
20665
20666 1 zcmusic_init();
20667 1 zcmixer = zcmixer_create();
20668 24 install_int_ex([](){ zcmusic_poll(); }, MSEC_TO_TIMER(25));
20669
20670 1 set_color_depth(8);
20671
20672 1 set_close_button_callback((void (*)()) hit_close_button);
20673
20674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(used_switch(argc,argv,"-fullscreen"))
20675 {
20676 tempmode = GFX_AUTODETECT_FULLSCREEN;
20677 }
20678
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 else if(used_switch(argc,argv,"-windowed"))
20679 {
20680 tempmode=GFX_AUTODETECT_WINDOWED;
20681 }
20682
20683 1 zq_screen_w = LARGE_W;
20684 1 zq_screen_h = LARGE_H;
20685 1 window_width = zc_get_config("zquest","window_width",-1);
20686 1 window_height = zc_get_config("zquest","window_height",-1);
20687 1 auto [w, h] = zc_get_default_display_size(LARGE_W, LARGE_H, window_width, window_height);
20688
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 int32_t videofail = is_headless() ? 0 : (set_gfx_mode(tempmode,w,h,zq_screen_w,zq_screen_h));
20689
20690 //extra block here is intentional
20691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(videofail!=0)
20692 {
20693 quit_game();
20694 allegro_exit();
20695 }
20696
20697 1 zalleg_create_window();
20698 1 Z_message("gfx mode set at -%d %dbpp %d x %d \n",
20699 1 tempmode, get_color_depth(), zq_screen_w, zq_screen_h);
20700
20701 1 set_window_title("ZC Editor");
20702
20703 1 load_size_poses();
20704
20705
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (!is_headless())
20706 {
20707 // Just in case.
20708 while (!all_get_display()) {
20709 al_rest(1);
20710 }
20711
20712 al_resize_display(all_get_display(), w, h);
20713 }
20714
20715
20716 #ifndef __EMSCRIPTEN__
20717
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if (!all_get_fullscreen_flag() && !is_headless()) {
20718 al_resize_display(all_get_display(), w, h);
20719
20720 int window_w = al_get_display_width(all_get_display());
20721 int window_h = al_get_display_height(all_get_display());
20722
20723 int new_x = zc_get_config("zquest","window_x",0);
20724 int new_y = zc_get_config("zquest","window_y",0);
20725 if(zc_get_config("zquest","save_window_position",0) && (new_x || new_y))
20726 {
20727 //load saved position
20728 //already stored in new_x/new_y
20729 }
20730 else
20731 {
20732 //Get default position
20733 ALLEGRO_MONITOR_INFO info;
20734 al_get_monitor_info(0, &info);
20735
20736 int mw = (info.x2 - info.x1);
20737 int mh = (info.y2 - info.y1);
20738 new_x = mw / 2 - window_w / 2;
20739 new_y = mh / 2 - window_h / 2;
20740 //Don't spawn the window too far down (taskbar?)
20741 if(new_y + window_h > mh - 72)
20742 new_y = mh-72-window_h;
20743 }
20744 #ifdef ALLEGRO_MACOSX
20745 if (zc_get_config("zquest","save_window_position",0))
20746 al_set_window_position(all_get_display(), new_x, new_y);
20747 #else
20748 al_set_window_position(all_get_display(), new_x, new_y);
20749 #endif
20750 }
20751 #endif
20752
20753 1 position_mouse(zq_screen_w/2,zq_screen_h/2);
20754
20755 1 dmapbmp_small = create_bitmap_ex(8,65,33);
20756 1 dmapbmp_large = create_bitmap_ex(8,177,81);
20757
20758
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!screen2 || !dmapbmp_large || !dmapbmp_large || !brushbmp || !brushscreen)// || !brushshadowbmp )
20759 {
20760 Z_error_fatal("Failed to create system bitmaps!\n");
20761 return 1;
20762 }
20763
20764
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (!is_headless())
20765 {
20766 zc_set_palette(asset_pal);
20767 get_palette(RAMpal);
20768 load_colorset(gui_colorset);
20769 zc_set_palette(RAMpal);
20770 clear_to_color(screen,vc(0));
20771 }
20772
20773 1 zScript = string();
20774 1 strcpy(zScriptBytes, "0 Bytes in Buffer");
20775
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 1 times.
13 for(int32_t i=0; i<MOUSE_BMP_MAX; i++)
20776 {
20777
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 12 times.
60 for(int32_t j=0; j<4; j++)
20778 {
20779 48 mouse_bmp[i][j] = NULL;
20780 48 mouse_bmp_1x[i][j] = NULL;
20781 48 }
20782 12 }
20783 1 load_mice();
20784 1 gui_mouse_focus=0;
20785 1 MouseSprite::set(ZQM_NORMAL);
20786 1 render_zq(); // Ensure the rendering bitmaps are setup.
20787
20788 #ifdef __EMSCRIPTEN__
20789 em_mark_ready_status();
20790 #endif
20791
20792 1 load_icons();
20793
20794 1 bool load_last_timed_save=false;
20795
20796 1 load_recent_quests();
20797 1 refresh_recent_menu();
20798 //clearConsole();
20799
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1 if((last_timed_save[0]!=0)&&(exists(last_timed_save)))
20800 {
20801 if(jwin_alert("ZQuest","It appears that ZQuest crashed last time.","Would you like to load the last timed save?",NULL,"&Yes","&No",'y','n',get_zc_font(font_lfont))==1)
20802 {
20803 int32_t ret = load_quest(last_timed_save);
20804
20805 if(ret == qe_OK)
20806 {
20807 strcpy(filepath,last_timed_save);
20808 load_last_timed_save=true;
20809 mark_save_dirty();
20810 }
20811 else
20812 {
20813 jwin_alert("Error","Unable to reload the last timed save.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
20814 }
20815 }
20816 }
20817
20818
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!load_last_timed_save)
20819 {
20820 1 strcpy(filepath,zc_get_config("zquest",last_quest_name,""));
20821
20822
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(argc>1 && argv[1][0]!='-')
20823 {
20824 int32_t ret = load_quest(argv[1]);
20825
20826 if(ret == qe_OK)
20827 {
20828 first_save=true;
20829 strcpy(filepath,argv[1]);
20830 refresh(rALL);
20831 }
20832 }
20833
2/8
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1 else if(OpenLastQuest&&filepath[0]&&exists(filepath)&&!used_switch(argc,argv,"-new"))
20834 {
20835 int32_t ret = load_quest(filepath);
20836
20837 if(ret == qe_OK)
20838 {
20839 first_save=true;
20840 refresh(rALL);
20841 }
20842 else
20843 {
20844 filepath[0]=temppath[0]=0;
20845 first_save=false;
20846 }
20847 }
20848 else
20849 {
20850
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (onNew() == D_CLOSE)
20851 {
20852 1 Z_message("User canceled creating new quest, closing.\n");
20853 1 exit(0);
20854 }
20855
20856 //otherwise the blank quest gets the name of the last loaded quest... not good! -DD
20857 filepath[0]=temppath[0]=0;
20858 first_save=false;
20859 }
20860 }
20861
20862 if(used_switch(argc,argv,"-q"))
20863 {
20864 Z_message("-q switch used, quitting program.\n");
20865 zq_exit(0);
20866 }
20867
20868 for(int32_t x=0; x<MAXITEMS; x++)
20869 {
20870 lens_hint_item[x][0]=0;
20871 lens_hint_item[x][1]=0;
20872 }
20873
20874 for(int32_t x=0; x<MAXWPNS; x++)
20875 {
20876 lens_hint_weapon[x][0]=0;
20877 lens_hint_weapon[x][1]=0;
20878 }
20879
20880 load_selections();
20881 load_arrows();
20882 DIALOG_PLAYER *player2=init_dialog(dialogs,-1);
20883
20884 get_palette(RAMpal);
20885
20886 rgb_map = zq_rgb_table;
20887
20888 #ifdef __EMSCRIPTEN__
20889 {
20890 int qs_map = EM_ASM_INT({
20891 return new URL(location.href).searchParams.get('map') ?? -1;
20892 });
20893 int qs_screen = EM_ASM_INT({
20894 return new URL(location.href).searchParams.get('screen') ?? -1;
20895 });
20896 if (qs_map != -1 && qs_screen != -1) {
20897 Map.setCurrMap(qs_map);
20898 Map.setCurrScr(qs_screen);
20899 }
20900 }
20901 #endif
20902
20903 // setup_combo_animations();
20904 pause_refresh = false;
20905 refresh_pal();
20906 refresh(rALL);
20907 for(int q = 0; q < brush_width_menu.size(); ++q)
20908 brush_width_menu.at(q)->select(q==0);
20909 for(int q = 0; q < brush_height_menu.size(); ++q)
20910 brush_height_menu.at(q)->select(q==0);
20911 set_filltype(1);
20912
20913 rebuild_trans_table();
20914
20915 if (!is_headless())
20916 {
20917 set_display_switch_mode(SWITCH_BACKGROUND);
20918 set_display_switch_callback(SWITCH_OUT, switch_out);
20919 set_display_switch_callback(SWITCH_IN, switch_in);
20920 }
20921
20922 if(!update_dialog(player2))
20923 exiting_program = true;
20924 //clear_keybuf();
20925 media_menu.disable_uid(MENUID_MEDIA_CHANGETRACK, true);
20926 disable_hotkey(ZQKEY_CHANGE_TRACK, true);
20927
20928 fix_drawing_mode_menu();
20929
20930
20931 #ifdef _WIN32
20932
20933 if(zqUseWin32Proc != FALSE)
20934 {
20935 al_trace("Config file warning: \"zq_win_proc_fix\" enabled switch found. This can cause crashes on some computers.\n");
20936 win32data.zqSetDefaultThreadPriority(0);
20937 win32data.zqSetCustomCallbackProc(al_get_win_window_handle(all_get_display()));
20938 }
20939
20940 #endif
20941
20942 time(&auto_save_time_start);
20943
20944 FFCore.init();
20945 ZQincludePaths = FFCore.includePaths;
20946
20947 Map.setCopyFFC(-1); //Do not have an initial ffc on the clipboard.
20948 brush_menu.select_uid(MENUID_BRUSH_AUTOBRUSH, AutoBrush);
20949 brush_menu.disable_uid(MENUID_BRUSH_WIDTH, AutoBrush);
20950 brush_menu.disable_uid(MENUID_BRUSH_HEIGHT, AutoBrush);
20951 brush_menu.select_uid(MENUID_BRUSH_COMBOBRUSH, ComboBrush);
20952 brush_menu.select_uid(MENUID_BRUSH_FLOATBRUSH, FloatBrush);
20953
20954 call_foo_dlg();
20955
20956 application_has_loaded = true;
20957
20958 while(!exiting_program)
20959 {
20960 handle_sentry_tags();
20961
20962 #ifdef _WIN32
20963 if(zqUseWin32Proc != FALSE)
20964 win32data.Update(Frameskip); //experimental win32 fixes
20965 #endif
20966 check_autosave();
20967 ++alignment_arrow_timer;
20968
20969 if(alignment_arrow_timer>63)
20970 {
20971 alignment_arrow_timer=0;
20972 }
20973 ++frame;
20974
20975 file_menu.disable_uid(MENUID_FILE_SAVE, saved||disable_saving||OverwriteProtection);
20976 file_menu.disable_uid(MENUID_FILE_REVERT, saved||disable_saving||OverwriteProtection);
20977 file_menu.disable_uid(MENUID_FILE_SAVEAS, disable_saving);
20978
20979 fixtools_menu.disable_uid(MENUID_FIXTOOL_OLDSTRING,
20980 !(get_qr(qr_OLD_STRING_EDITOR_MARGINS)
20981 ||get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)));
20982
20983 edit_menu.disable_uid(MENUID_EDIT_UNDO, !Map.CanUndo());
20984 edit_menu.disable_uid(MENUID_EDIT_REDO, !Map.CanRedo());
20985
20986 bool canpaste = Map.CanPaste();
20987 edit_menu.disable_uid(MENUID_EDIT_PASTE, !canpaste);
20988 edit_menu.disable_uid(MENUID_EDIT_PASTEALL, !canpaste);
20989 edit_menu.disable_uid(MENUID_EDIT_ADVPASTE, !canpaste);
20990 edit_menu.disable_uid(MENUID_EDIT_SPECPASTE, !canpaste);
20991 rc_menu_screen.disable_uid(MENUID_RCSCREEN_PASTE, !canpaste);
20992 rc_menu_screen.disable_uid(MENUID_RCSCREEN_ADVPASTE, !canpaste);
20993 rc_menu_screen.disable_uid(MENUID_RCSCREEN_SPECPASTE, !canpaste);
20994 for(MenuItem& mit : paste_menu.inner())
20995 mit.disable(!canpaste);
20996 for(MenuItem& mit : paste_item_menu.inner())
20997 mit.disable(!canpaste);
20998
20999 edit_menu.disable_uid(MENUID_EDIT_COPY, !(Map.CurrScr()->valid&mVALID));
21000 edit_menu.disable_uid(MENUID_EDIT_DELETE, !(Map.CurrScr()->valid&mVALID));
21001
21002 // Are some things selected?
21003 view_menu.select_uid(MENUID_VIEW_WALKABILITY, Flags&cWALK);
21004 view_menu.select_uid(MENUID_VIEW_FLAGS, Flags&cFLAGS);
21005 view_menu.select_uid(MENUID_VIEW_CSET, Flags&cCSET);
21006 view_menu.select_uid(MENUID_VIEW_TYPES, Flags&cCTYPE);
21007 view_menu.select_uid(MENUID_VIEW_INFO, ShowInfo);
21008 view_menu.select_uid(MENUID_VIEW_SQUARES, ShowSquares);
21009 view_menu.select_uid(MENUID_VIEW_FFCS, ShowFFCs);
21010 view_menu.select_uid(MENUID_VIEW_SCRIPTNAMES, ShowFFScripts);
21011 view_menu.select_uid(MENUID_VIEW_GRID, ShowGrid);
21012 view_menu.select_uid(MENUID_VIEW_SCREENGRID, ShowScreenGrid);
21013 view_menu.select_uid(MENUID_VIEW_REGIONGRID, ShowRegionGrid);
21014 view_menu.select_uid(MENUID_VIEW_CURSCROUTLINE, ShowCurScreenOutline);
21015 view_menu.select_uid(MENUID_VIEW_DARKNESS, get_qr(qr_NEW_DARKROOM) && (Flags&cNEWDARK));
21016 view_menu.select_uid(MENUID_VIEW_L2BG, ViewLayer2BG);
21017 view_menu.select_uid(MENUID_VIEW_L3BG, ViewLayer3BG);
21018 view_menu.select_uid(MENUID_VIEW_LAYERHIGHLIGHT, ActiveLayerHighlight);
21019 view_menu.select_uid(MENUID_VIEW_HIGH_QUALITY_SCREEN_RENDERING, HighQualityScreenRendering);
21020
21021 maps_menu.disable_uid(MENUID_MAPS_NEXT, !map_count || Map.getCurrMap() >= map_count);
21022 maps_menu.disable_uid(MENUID_MAPS_PREV, Map.getCurrMap()<=0);
21023
21024 etc_menu.disable_uid(MENUID_ETC_VIDMODE, isFullScreen()==1);
21025 etc_menu.select_uid(MENUID_ETC_FULLSCREEN, isFullScreen()==1);
21026
21027 if(!update_dialog(player2))
21028 exiting_program = true;
21029
21030 //clear_keybuf();
21031 handle_close_btn_quit();
21032 }
21033
21034 zq_exit(0);
21035 return 0;
21036 }
21037 END_OF_MAIN()
21038
21039 11 void zq_exit(int code)
21040 {
21041 11 set_is_exiting();
21042 11 parser_console.kill();
21043 11 killConsole();
21044
21045 11 quit_game();
21046 11 allegro_exit();
21047 11 exit(code);
21048 }
21049
21050 4 void init_bitmap(BITMAP** bmp, int32_t w, int32_t h)
21051 {
21052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(*bmp)
21053 destroy_bitmap(*bmp);
21054 4 *bmp = create_bitmap_ex(8,w,h);
21055 4 clear_bitmap(*bmp);
21056 4 }
21057 1 void load_size_poses()
21058 {
21059 1 ttip_uninstall_all();
21060
21061 1 FONT* favcmdfont = get_custom_font(CFONT_FAVCMD);
21062 1 FONT* guifont = get_custom_font(CFONT_GUI);
21063
21064 1 d_nbmenu_proc(MSG_START, &dialogs[0], 0);
21065
21066 1 commands_list.xscale = command_buttonwidth;
21067 1 commands_list.yscale = 10+text_height(favcmdfont);
21068
21069 1 auto drawmode_wid = 64;
21070
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1 times.
7 for(auto q = 0; q < dm_max; ++q)
21071 {
21072 6 auto wid = text_length(guifont, dm_names[q]);
21073
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(wid > drawmode_wid)
21074 drawmode_wid = wid;
21075 6 }
21076
21077 //Main GUI objects
21078
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(is_compact)
21079 {
21080 1 num_combo_cols = 2;
21081 1 combo_col_scale = 16;
21082
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(compact_merged_combopane)
21083 {
21084 1 num_combo_cols = 1;
21085 1 combo_col_scale = 32;
21086 1 }
21087
21088 1 mapscreen_x=0;
21089 1 mapscreen_y=dialogs[0].h;
21090 1 mapscreen_screenunit_scale=3;
21091 1 mapscreen_single_scale = (double)mapscreen_screenunit_scale / Map.getViewSize();
21092 1 showedges=0;
21093 1 showallpanels=0;
21094
21095 1 blackout_color=8;
21096
21097 1 auto mapscr_wid = (((showedges?2:0)+16)*16*mapscreen_screenunit_scale);
21098 1 combolist_window.w=zq_screen_w-mapscr_wid;
21099 1 combolist_window.x=zq_screen_w-combolist_window.w;
21100
21101 1 favorites_window.x=combolist_window.x;
21102 1 favorites_window.w=combolist_window.w;
21103 1 favorites_window.h=136;
21104 1 favorites_window.y=zq_screen_h-favorites_window.h;
21105
21106 1 combolist_window.y=0;
21107 1 combolist_window.h=favorites_window.y-combolist_window.y;
21108
21109 1 combo_preview.x=zq_screen_w-32-8;
21110 1 combo_preview.y=combolist_window.y+6;
21111 1 combo_preview.w=32;
21112 1 combo_preview.h=32;
21113 1 combo_preview2.clear();
21114
21115 1 auto col_wid = 4*combo_col_scale;
21116 1 auto cols_wid = col_wid * num_combo_cols;
21117 1 auto cols_spacing = (combolist_window.w-cols_wid)/(num_combo_cols+1);
21118
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 for(auto q = 0; q < num_combo_cols; ++q)
21119 {
21120 1 combolist[q].x=combolist_window.x+(cols_spacing*(q+1))+(col_wid*q);
21121 1 combolist[q].y=combolist_window.y+54;
21122 1 combolist[q].w=4;
21123 1 combolist[q].h=compact_merged_combopane ? 15 : 30;
21124 1 combolist[q].xscale = combo_col_scale;
21125 1 combolist[q].yscale = combo_col_scale;
21126
21127 1 comboaliaslist[q].x = combolist[q].x;
21128 1 comboaliaslist[q].y = combolist[q].y;
21129 1 comboaliaslist[q].w = 4;
21130 1 comboaliaslist[q].h = compact_merged_combopane ? 13 : 26;
21131 1 comboaliaslist[q].xscale = combo_col_scale;
21132 1 comboaliaslist[q].yscale = combo_col_scale;
21133
21134 1 combolistscrollers[q].w=2;
21135 1 combolistscrollers[q].h=1;
21136 1 combolistscrollers[q].xscale=11;
21137 1 combolistscrollers[q].yscale=11;
21138 1 combolistscrollers[q].x=combolist[q].x+(combolist[q].w*combolist[q].xscale/2)-11;
21139 1 combolistscrollers[q].y=combolist[q].y-combolistscrollers[q].th()-3;
21140 1 }
21141
21142 1 comboalias_preview.x=zq_screen_w-((combolist_window.w+64)/2);
21143 1 comboalias_preview.h=64;
21144 1 comboalias_preview.y=favorites_window.y-comboalias_preview.h-8;
21145 1 comboalias_preview.w=64;
21146
21147 1 combo_merge_btn.w = 20;
21148 1 combo_merge_btn.h = 20;
21149 1 combo_merge_btn.x = zq_screen_w-(combolist_window.w+combo_merge_btn.w)/2;
21150 1 combo_merge_btn.y = combolist[0].y-combo_merge_btn.h;
21151
21152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(num_combo_cols == 1)
21153 {
21154 1 combolistscrollers[0].x += 34;
21155 1 }
21156 1 drawmode_btn.x = combolist_window.x-drawmode_wid;
21157 1 drawmode_btn.y = 0;
21158 1 drawmode_btn.w = drawmode_wid;
21159 1 drawmode_btn.h = mapscreen_y;
21160
21161 1 compactbtn.w = text_length(guifont,"> Compact")+10;
21162 1 compactbtn.x = drawmode_btn.x-compactbtn.w;
21163 1 compactbtn.y = drawmode_btn.y;
21164 1 compactbtn.h = drawmode_btn.h;
21165
21166 1 zoominbtn.w = text_length(guifont,"+")+10;
21167 1 zoominbtn.x = compactbtn.x-zoominbtn.w;
21168 1 zoominbtn.y = compactbtn.y;
21169 1 zoominbtn.h = compactbtn.h;
21170
21171 1 zoomoutbtn.w = text_length(guifont,"-")+10;
21172 1 zoomoutbtn.x = zoominbtn.x-zoomoutbtn.w;
21173 1 zoomoutbtn.y = compactbtn.y;
21174 1 zoomoutbtn.h = compactbtn.h;
21175
21176
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1 times.
10 for(int32_t i=0; i<=8; i++)
21177 {
21178 9 map_page_bar[i].w = 48;
21179 9 map_page_bar[i].x = mapscreen_x+(i*48);
21180 9 map_page_bar[i].y = mapscreen_y+(11*16*mapscreen_screenunit_scale);
21181 9 map_page_bar[i].h = text_height(guifont)+12;
21182 9 }
21183
21184 1 minimap.w=7+48*3;
21185 1 minimap.h=16+27*3;
21186
21187 1 layer_panel.x=map_page_bar[6].x;
21188 1 layer_panel.y=map_page_bar[0].y;
21189 1 layer_panel.w=combolist_window.x - layer_panel.x;
21190 1 layer_panel.h=map_page_bar[0].h;
21191 1 layerpanel_buttonwidth = 51;
21192 1 layerpanel_buttonheight = layer_panel.h;
21193 1 layerpanel_checkbox_hei = layerpanel_buttonheight-4;
21194 1 layerpanel_checkbox_wid = 15;
21195
21196 1 minimap.x=3;
21197 1 minimap.y=layer_panel.y+layer_panel.h+4;
21198
21199 1 real_minimap.x = minimap.x+3;
21200 1 real_minimap.y = minimap.y+5;
21201 1 real_minimap.w = 16;
21202 1 real_minimap.h = 9;
21203 1 real_minimap.xscale = 9;
21204 1 real_minimap.yscale = 9;
21205 1 real_minimap.fw = real_minimap.xscale*8;
21206 1 real_minimap.fh = real_minimap.yscale*8;
21207
21208 1 int upscale_mm = 3;
21209 1 int xwid = real_minimap.tw()*(upscale_mm-1);
21210 1 int xhei = real_minimap.th()*(upscale_mm-1);
21211 1 minimap_zoomed.set(minimap.x, minimap.y-xhei, minimap.w+xwid, minimap.h+xhei+4);
21212 1 real_minimap_zoomed.set(minimap_zoomed.x+3, minimap_zoomed.y+5, real_minimap.w, real_minimap.h, real_minimap.xscale*upscale_mm, real_minimap.yscale*upscale_mm);
21213 1 real_minimap_zoomed.fw = real_minimap_zoomed.xscale*8;
21214 1 real_minimap_zoomed.fh = real_minimap_zoomed.yscale*8;
21215
21216 1 screrrorpos.x = combolist_window.x - 3;
21217 1 screrrorpos.y = layer_panel.y - 16;
21218
21219 1 mouse_scroll_h=10;
21220
21221 1 favorites_list.x=favorites_window.x+8;
21222 1 favorites_list.y=favorites_window.y+16;
21223 1 favorites_list.xscale = 16;
21224 1 favorites_list.yscale = 16;
21225 1 favorites_list.w=(favorites_window.w-16)/favorites_list.xscale;
21226 1 favorites_list.h=(favorites_window.h-24)/favorites_list.yscale;
21227
21228 1 commands_list.w=4;
21229
21230 1 int bh = commands_list.yscale;
21231 1 int bw = 26;
21232 1 commands_window.w=commands_list.w*commands_list.xscale+10+bw;
21233 1 commands_window.x=combolist_window.x-commands_window.w;
21234 1 commands_window.y=layer_panel.y+layer_panel.h;
21235 1 commands_window.h=zq_screen_h-commands_window.y;
21236 1 int bx = commands_window.x+2;
21237
21238 1 commands_list.y=commands_window.y+4;
21239 1 commands_list.h=(zq_screen_h - commands_list.y) / commands_list.yscale;
21240 1 commands_list.x=bx+bw;
21241
21242 1 commands_zoombtn.w = bw;
21243 1 commands_zoombtn.h = bh;
21244 1 commands_zoombtn.x = bx;
21245 1 commands_zoombtn.y = commands_list.y;
21246
21247 1 commands_infobtn.w = bw;
21248 1 commands_infobtn.h = bh;
21249 1 commands_infobtn.x = bx;
21250 1 commands_infobtn.y = commands_zoombtn.y + commands_infobtn.h;
21251
21252 1 commands_x.w = bw;
21253 1 commands_x.h = bh;
21254 1 commands_x.x = bx;
21255 1 commands_x.y = commands_infobtn.y + commands_x.h;
21256
21257 1 commands_txt.clear();
21258
21259 1 main_panel.x = 0;
21260 1 main_panel.y = layer_panel.y+layer_panel.h;
21261 1 main_panel.w = commands_window.x - main_panel.x;
21262 1 main_panel.h = 76+32;
21263 1 preview_panel = main_panel;
21264 1 preview_panel.x = 0;
21265 1 preview_panel.w = commands_window.x - preview_panel.x;
21266
21267 1 preview_text.x = preview_panel.x+3;
21268 1 preview_text.y = preview_panel.y+3;
21269 1 preview_text.w = 2;
21270 1 preview_text.h = 6;
21271 1 preview_text.xscale = 10;
21272 1 preview_text.yscale = text_height(get_zc_font(font_lfont_l));
21273
21274 1 panel_align = 1;
21275 1 int swapbtnw = 32, swapbtnh = 20;
21276 1 int swapbtnx = main_panel.x+main_panel.tw()-swapbtnw;
21277 1 squarepanel_swap_btn.set(swapbtnx, zq_screen_h-swapbtnh, swapbtnw, swapbtnh);
21278
21279 1 int sqx = minimap.x+minimap.tw();
21280 1 squares_panel.set(sqx,main_panel.y,main_panel.tw()-sqx,main_panel.th());
21281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(compact_square_panels)
21282 {
21283 int cmpy = main_panel.y+(main_panel.th()/2);
21284 squarepanel_up_btn.set(swapbtnx, cmpy-swapbtnh, swapbtnw, swapbtnh);
21285 squarepanel_down_btn.set(swapbtnx, cmpy, swapbtnw, swapbtnh);
21286
21287 txtoffs_single.x = 18;
21288 txtoffs_single.y = 36;
21289 txtoffs_double_1.x = 18;
21290 txtoffs_double_1.y = 36;
21291 txtoffs_double_2.x = 18;
21292 txtoffs_double_2.y = 36 + text_height(get_custom_font(CFONT_GUI));
21293
21294 //Clear them all- if they stay cleared, they are invisible.
21295 itemsqr_pos.clear();
21296 stairsqr_pos.clear();
21297 warparrival_pos.clear();
21298 flagsqr_pos.clear();
21299 enemy_prev_pos.clear();
21300 for(int q = 0; q < 4; ++q)
21301 warpret_pos[q].clear();
21302
21303 int sqr_x1 = sqx+12;
21304 int sqr_y1 = main_panel.y+12;
21305 int sqr_xoffs = (16*2)+4 + 12;
21306 switch(compact_active_panel)
21307 {
21308 case 0: //Warp Squares
21309 {
21310 int x = sqr_x1;
21311 for(int q = 0; q < 4; ++q)
21312 {
21313 warpret_pos[q].set(x,sqr_y1,(16*2)+4,(16*2)+4);
21314 x += sqr_xoffs;
21315 }
21316 break;
21317 }
21318 case 1: //Other Squares
21319 {
21320 itemsqr_pos.set(sqr_x1+(sqr_xoffs*0), sqr_y1, (16*2)+4,(16*2)+4);
21321 stairsqr_pos.set(sqr_x1+(sqr_xoffs*1), sqr_y1, (16*2)+4,(16*2)+4);
21322 warparrival_pos.set(sqr_x1+(sqr_xoffs*2), sqr_y1, (16*2)+4,(16*2)+4);
21323 flagsqr_pos.set(sqr_x1+(sqr_xoffs*3), sqr_y1, (16*2)+4,(16*2)+4);
21324 break;
21325 }
21326 case 2: //Enemy Preview
21327 {
21328 enemy_prev_pos.set(sqr_x1, sqr_y1, 5, 2, 32, 32);
21329 break;
21330 }
21331 }
21332 }
21333 else
21334 {
21335 1 squarepanel_up_btn.clear();
21336 1 squarepanel_down_btn.clear();
21337 1 txtoffs_single.x = 10;
21338 1 txtoffs_single.y = 22;
21339 1 txtoffs_double_1.x = 10;
21340 1 txtoffs_double_1.y = 22;
21341 1 txtoffs_double_2.x = 10;
21342 1 txtoffs_double_2.y = 30;
21343
21344
21345 1 int sqr_x1 = sqx+24;
21346 1 int sqr_y1 = main_panel.y+12;
21347 1 int sqr_y2 = sqr_y1+42;
21348 1 int sqr_xdist = 32;
21349 1 itemsqr_pos.set(sqr_x1+(sqr_xdist*0),sqr_y1,20,20);
21350 1 stairsqr_pos.set(sqr_x1+(sqr_xdist*1),sqr_y1,20,20);
21351 1 warparrival_pos.set(sqr_x1+(sqr_xdist*2),sqr_y1,20,20);
21352 1 flagsqr_pos.set(sqr_x1+(sqr_xdist*3),sqr_y1,20,20);
21353
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(auto q = 0; q < 4; ++q)
21354 {
21355 4 warpret_pos[q].set(sqr_x1+(sqr_xdist*q),sqr_y2,20,20);
21356 4 }
21357 1 enemy_prev_pos.set(sqr_x1+(sqr_xdist*4), sqr_y1, 4, 3, 16, 16);
21358 1 enemy_prev_pos.fw = enemy_prev_pos.xscale*2;
21359 1 enemy_prev_pos.fh = enemy_prev_pos.yscale*2;
21360 }
21361
21362 1 auto& last_alias_list = comboaliaslist[num_combo_cols-1];
21363 1 combopool_preview.x=comboaliaslist[0].x;
21364 1 combopool_preview.y=last_alias_list.y+(last_alias_list.h*last_alias_list.yscale)+16;
21365 1 combopool_preview.w=(last_alias_list.x+(last_alias_list.w*last_alias_list.xscale))-comboaliaslist[0].x;
21366 1 combopool_preview.h=zq_screen_h-8-combopool_preview.y;
21367 1 combopool_preview.w -= combopool_preview.w%16;
21368 1 combopool_preview.h -= combopool_preview.h%16;
21369
21370 1 FONT* tfont = get_zc_font(font_lfont_l);
21371 1 combopool_prevbtn.w = text_length(tfont, "Unweighted")+10;
21372 1 combopool_prevbtn.h = 11;
21373 1 combopool_prevbtn.x = combopool_preview.x;
21374 1 combopool_prevbtn.y = combopool_preview.y-combopool_prevbtn.h;
21375
21376 1 mappage_count = 6;
21377
21378 1 txfont = get_zc_font(font_lfont_l);
21379 1 combo_preview_text1.set(combo_preview.x-5,combo_preview.y,1,3,1,text_height(txfont));
21380 1 combo_preview_text2.clear();
21381
21382 1 favorites_x.w = 17;
21383 1 favorites_infobtn.w = 17;
21384 1 favorites_zoombtn.w = 17;
21385 1 favorites_pgleft.w = 17;
21386 1 favorites_pgright.w = 17;
21387 1 }
21388 else
21389 {
21390 num_combo_cols = 4;
21391 combo_col_scale = 16;
21392 if(large_merged_combopane)
21393 {
21394 num_combo_cols = 2;
21395 combo_col_scale = 32;
21396 }
21397
21398 mapscreen_x=0;
21399 mapscreen_y=dialogs[0].h;
21400 mapscreen_screenunit_scale=2;
21401 mapscreen_single_scale = (double)mapscreen_screenunit_scale / Map.getViewSize();
21402 if (HighQualityScreenRendering)
21403 showedges=Map.getViewSize() == 1 ? 1 : 0;
21404 else
21405 showedges=Map.getViewSize() <= 2 ? 1 : 0;
21406 showallpanels=0;
21407
21408 blackout_color=8;
21409
21410 favorites_window.h=136;
21411 favorites_window.y=zq_screen_h-favorites_window.h;
21412
21413 auto mapscr_wid = (((2)+16)*16*mapscreen_screenunit_scale);
21414 combolist_window.w=zq_screen_w-mapscr_wid;
21415 combolist_window.x=zq_screen_w-combolist_window.w;
21416 combolist_window.y=0;
21417 combolist_window.h=favorites_window.y-combolist_window.y;
21418
21419 favorites_window.x=combolist_window.x;
21420 favorites_window.w=combolist_window.w;
21421
21422 combo_preview.x=(zq_screen_w-(combolist_window.w/2))-40;
21423 combo_preview.y=combolist_window.y+6;
21424 combo_preview.w=32;
21425 combo_preview.h=32;
21426 combo_preview2 = combo_preview;
21427 combo_preview2.x += 48;
21428
21429 auto col_wid = 4*combo_col_scale;
21430 auto cols_wid = col_wid * num_combo_cols;
21431 auto cols_spacing = (combolist_window.w-cols_wid)/(num_combo_cols+1);
21432 for(auto q = 0; q < num_combo_cols; ++q)
21433 {
21434 combolist[q].x=combolist_window.x+(cols_spacing*(q+1))+(col_wid*q);
21435 combolist[q].y=combolist_window.y+60;
21436 combolist[q].w=4;
21437 combolist[q].h=large_merged_combopane ? 15 : 30;
21438 combolist[q].xscale = combo_col_scale;
21439 combolist[q].yscale = combo_col_scale;
21440
21441 comboaliaslist[q].x=combolist[q].x;
21442 comboaliaslist[q].y=combolist[q].y;
21443 comboaliaslist[q].w=4;
21444 comboaliaslist[q].h=large_merged_combopane ? 12 : 25;
21445 comboaliaslist[q].xscale = combo_col_scale;
21446 comboaliaslist[q].yscale = combo_col_scale;
21447
21448 combolistscrollers[q].w=2;
21449 combolistscrollers[q].h=1;
21450 combolistscrollers[q].xscale=11;
21451 combolistscrollers[q].yscale=11;
21452 combolistscrollers[q].x=combolist[q].x+(combolist[q].w*combolist[q].xscale/2)-11;
21453 combolistscrollers[q].y=combolist[q].y-combolistscrollers[q].th()-2;
21454 }
21455
21456 comboalias_preview.x=zq_screen_w-((combolist_window.w+64)/2);
21457 comboalias_preview.h=64;
21458 comboalias_preview.w=64;
21459 comboalias_preview.y=favorites_window.y-comboalias_preview.h-8;
21460
21461 combo_merge_btn.w = 20;
21462 combo_merge_btn.h = 20;
21463 combo_merge_btn.x = zq_screen_w-(combolist_window.w+combo_merge_btn.w)/2;
21464 combo_merge_btn.y = combolist[0].y-combo_merge_btn.h;
21465 squarepanel_swap_btn.clear();
21466 squarepanel_up_btn.clear();
21467 squarepanel_down_btn.clear();
21468
21469 drawmode_btn.x = combolist_window.x-drawmode_wid;
21470 drawmode_btn.y = 0;
21471 drawmode_btn.w = drawmode_wid;
21472 drawmode_btn.h = mapscreen_y;
21473
21474 compactbtn.w = text_length(guifont,"> Compact")+10;
21475 compactbtn.x = drawmode_btn.x-compactbtn.w;
21476 compactbtn.y = drawmode_btn.y;
21477 compactbtn.h = drawmode_btn.h;
21478
21479 zoominbtn.w = text_length(guifont,"+")+10;
21480 zoominbtn.x = compactbtn.x-zoominbtn.w;
21481 zoominbtn.y = compactbtn.y;
21482 zoominbtn.h = compactbtn.h;
21483
21484 zoomoutbtn.w = text_length(guifont,"-")+10;
21485 zoomoutbtn.x = zoominbtn.x-zoomoutbtn.w;
21486 zoomoutbtn.y = compactbtn.y;
21487 zoomoutbtn.h = compactbtn.h;
21488
21489 for(int32_t i=0; i<=8; i++)
21490 {
21491 map_page_bar[i].x = mapscreen_x+(i*16*2*mapscreen_screenunit_scale);
21492 map_page_bar[i].y = mapscreen_y+((13)*16*mapscreen_screenunit_scale);
21493 map_page_bar[i].w = 64;
21494 map_page_bar[i].h = text_height(guifont)+12;
21495 }
21496
21497 minimap.w=7+48*3;
21498 minimap.h=16+27*3;
21499
21500 layer_panel.x=map_page_bar[0].x;
21501 layer_panel.y=map_page_bar[0].y+map_page_bar[0].h;
21502 layer_panel.w=map_page_bar[8].x+map_page_bar[8].w;
21503 layer_panel.h=text_height(guifont)+8;
21504 layerpanel_buttonwidth = 58;
21505 layerpanel_buttonheight = layer_panel.h;
21506 layerpanel_checkbox_hei = layerpanel_buttonheight-4;
21507 layerpanel_checkbox_wid = 14;
21508
21509 commands_list.w=4;
21510 commands_window.w=commands_list.w*commands_list.xscale+16;
21511 commands_window.x=combolist_window.x-commands_window.w;
21512 commands_window.y=layer_panel.y+layer_panel.h;
21513 commands_window.h=zq_screen_h-commands_window.y;
21514
21515 //buttons panel
21516 main_panel.x = 0;
21517 main_panel.y = layer_panel.y+layer_panel.h;
21518 main_panel.w = commands_window.x - main_panel.x;
21519 main_panel.h = zq_screen_h - main_panel.y;
21520 preview_panel = main_panel;
21521
21522 preview_text.x = preview_panel.x+3;
21523 preview_text.y = preview_panel.y+3;
21524 preview_text.w = 1;
21525 preview_text.h = 12;
21526 preview_text.xscale = 10;
21527 preview_text.yscale = text_height(get_zc_font(font_lfont_l));
21528
21529 minimap.x=3;
21530 minimap.y=main_panel.y+4;
21531
21532 real_minimap.x = minimap.x+3;
21533 real_minimap.y = minimap.y+5;
21534 real_minimap.w = 16;
21535 real_minimap.h = 9;
21536 real_minimap.xscale = 9;
21537 real_minimap.yscale = 9;
21538 real_minimap.fw = real_minimap.xscale*8;
21539 real_minimap.fh = real_minimap.yscale*8;
21540
21541 int upscale_mm = 4;
21542 int xwid = real_minimap.tw()*(upscale_mm-1);
21543 int xhei = real_minimap.th()*(upscale_mm-1);
21544 int zh = minimap.h+xhei+4;
21545 minimap_zoomed.set(minimap.x, zq_screen_h-zh, minimap.w+xwid, zh);
21546 real_minimap_zoomed.set(minimap_zoomed.x+3, minimap_zoomed.y+5, real_minimap.w, real_minimap.h, real_minimap.xscale*upscale_mm, real_minimap.yscale*upscale_mm);
21547 real_minimap_zoomed.fw = real_minimap_zoomed.xscale*8;
21548 real_minimap_zoomed.fh = real_minimap_zoomed.yscale*8;
21549
21550 screrrorpos.x = 575;
21551 screrrorpos.y = 388;
21552
21553 mouse_scroll_h=10;
21554
21555 favorites_list.x=favorites_window.x+8;
21556 favorites_list.y=favorites_window.y+16;
21557 favorites_list.xscale = 16;
21558 favorites_list.yscale = 16;
21559 favorites_list.w=(favorites_window.w-16)/favorites_list.xscale;
21560 favorites_list.h=(favorites_window.h-24)/favorites_list.yscale;
21561
21562 int bh = 16;
21563 int by = commands_window.y+4;
21564 commands_list.y=by+bh;
21565 commands_list.h=(zq_screen_h - commands_list.y) / commands_list.yscale;
21566 commands_list.x=commands_window.x+8;
21567
21568 commands_x.w = 20;
21569 commands_x.h = bh;
21570 commands_x.x = commands_list.x + commands_list.tw() - commands_x.w;
21571 commands_x.y = by;
21572
21573 commands_infobtn.w = 20;
21574 commands_infobtn.h = bh;
21575 commands_infobtn.x = commands_x.x - commands_infobtn.w;
21576 commands_infobtn.y = by;
21577
21578 commands_zoombtn.w = 20;
21579 commands_zoombtn.h = bh;
21580 commands_zoombtn.x = commands_infobtn.x - commands_zoombtn.w;
21581 commands_zoombtn.y = by;
21582
21583 commands_txt.x = commands_list.x;
21584 commands_txt.y = by+(bh-text_height(get_zc_font(font_lfont_l)))/2;
21585
21586 favorites_x.x = favorites_window.x + favorites_window.w - favorites_x.w - 2;
21587 favorites_x.y = favorites_list.y-15;
21588
21589 favorites_infobtn.x = favorites_x.x - favorites_infobtn.w;
21590 favorites_infobtn.y = favorites_x.y;
21591
21592 favorites_zoombtn.x = favorites_infobtn.x - favorites_zoombtn.w;
21593 favorites_zoombtn.y = favorites_infobtn.y;
21594
21595 favorites_pgright.x = favorites_zoombtn.x - favorites_pgright.w;
21596 favorites_pgright.y = favorites_zoombtn.y;
21597
21598 favorites_pgleft.x = favorites_pgright.x - favorites_pgleft.w;
21599 favorites_pgleft.y = favorites_pgleft.y;
21600
21601 txtoffs_single.x = 22;
21602 txtoffs_single.y = 6;
21603 txtoffs_double_1.x = 22;
21604 txtoffs_double_1.y = 2;
21605 txtoffs_double_2.x = 22;
21606 txtoffs_double_2.y = 10;
21607 panel_align = 0;
21608
21609 int sqx = minimap.x+minimap.tw();
21610 squares_panel.set(sqx,main_panel.y,main_panel.tw()-sqx,main_panel.th());
21611 int x2 = sqx+4;
21612 int x1 = x2 - (20+(8*3)+2);
21613 int y1 = main_panel.y+10;
21614 int sw = 20, sh = 20;
21615 int offs = sh+4;
21616
21617 itemsqr_pos.set(x2,y1+(0*offs),sw,sh);
21618 flagsqr_pos.set(x2,y1+(1*offs),sw,sh);
21619 stairsqr_pos.set(x2,y1+(2*offs),sw,sh);
21620 warparrival_pos.set(x2,y1+(6*offs),sw,sh);
21621
21622 enemy_prev_pos.x = main_panel.x+14;
21623 enemy_prev_pos.y = main_panel.y+12 + minimap.h;
21624 enemy_prev_pos.w = 4;
21625 enemy_prev_pos.h = 3;
21626 enemy_prev_pos.xscale = 16;
21627 enemy_prev_pos.yscale = 16;
21628 enemy_prev_pos.fw = enemy_prev_pos.xscale*2;
21629 enemy_prev_pos.fh = enemy_prev_pos.yscale*2;
21630
21631 warpret_pos[0].set(x1,y1+(4*offs),sw,sh);
21632 warpret_pos[1].set(x1,y1+(5*offs),sw,sh);
21633 warpret_pos[2].set(x2,y1+(4*offs),sw,sh);
21634 warpret_pos[3].set(x2,y1+(5*offs),sw,sh);
21635
21636 auto& last_alias_list = comboaliaslist[num_combo_cols-1];
21637 combopool_preview.x=comboaliaslist[0].x;
21638 combopool_preview.y=last_alias_list.y+(last_alias_list.h*last_alias_list.yscale)+16;
21639 combopool_preview.w=(last_alias_list.x+(last_alias_list.w*last_alias_list.xscale))-comboaliaslist[0].x;
21640 combopool_preview.h=(favorites_window.y-combopool_preview.y);//+favorites_window.h-10;
21641 combopool_preview.w -= combopool_preview.w%16;
21642 combopool_preview.h -= combopool_preview.h%16;
21643
21644 FONT* tfont = get_zc_font(font_lfont_l);
21645 combopool_prevbtn.w = text_length(tfont, "Unweighted")+10;
21646 combopool_prevbtn.h = 11;
21647 combopool_prevbtn.x = combopool_preview.x;
21648 combopool_prevbtn.y = combopool_preview.y-combopool_prevbtn.h;
21649
21650 mappage_count = 9;
21651
21652 txfont = get_zc_font(font_lfont_l);
21653 combo_preview_text1.set(combo_preview.x-9,combo_preview.y,1,3,1,text_height(txfont));
21654 combo_preview_text2.set(combo_preview2.x+combo_preview2.w+8,combo_preview2.y,1,3,1,text_height(txfont));
21655
21656 favorites_x.w = 30;
21657 favorites_infobtn.w = 30;
21658 favorites_zoombtn.w = 30;
21659 favorites_pgleft.w = 30;
21660 favorites_pgright.w = 30;
21661 }
21662 //Same in all modes
21663 {
21664
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(is_compact ? compact_zoomed_cmd : large_zoomed_cmd)
21665 {
21666 1 commands_list.w /= 2;
21667 1 commands_list.xscale *= 2;
21668 1 }
21669
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(is_compact ? compact_zoomed_fav : large_zoomed_fav)
21670 {
21671
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(favorites_list.w%2)
21672 favorites_list.x += (favorites_list.xscale / 2);
21673 1 favorites_list.xscale *= 2;
21674 1 favorites_list.yscale *= 2;
21675 1 favorites_list.w /= 2;
21676 1 favorites_list.h /= 2;
21677 1 }
21678
21679 1 favorites_x.h = 14;
21680 1 favorites_x.x = favorites_window.x + favorites_window.w - favorites_x.w - 2;
21681 1 favorites_x.y = favorites_list.y-15;
21682
21683 1 favorites_infobtn.h = favorites_x.h;
21684 1 favorites_infobtn.x = favorites_x.x - favorites_infobtn.w;
21685 1 favorites_infobtn.y = favorites_x.y;
21686
21687 1 favorites_zoombtn.h = favorites_infobtn.h;
21688 1 favorites_zoombtn.x = favorites_infobtn.x - favorites_zoombtn.w;
21689 1 favorites_zoombtn.y = favorites_infobtn.y;
21690
21691 1 favorites_pgright.h = favorites_zoombtn.h;
21692 1 favorites_pgright.x = favorites_zoombtn.x - favorites_pgright.w;
21693 1 favorites_pgright.y = favorites_zoombtn.y;
21694
21695 1 favorites_pgleft.h = favorites_pgright.h;
21696 1 favorites_pgleft.x = favorites_pgright.x - favorites_pgleft.w;
21697 1 favorites_pgleft.y = favorites_pgright.y;
21698
21699 1 mainbar.x = dialogs[0].x+dialogs[0].w;
21700 1 mainbar.y = 0;
21701 1 mainbar.w = zoomoutbtn.x-mainbar.x;
21702 1 mainbar.h = drawmode_btn.h;
21703 }
21704
21705 //Ensure current combo list selected is valid
21706 1 current_combolist=vbound(current_combolist,0,num_combo_cols-1);
21707 1 current_comboalist=vbound(current_comboalist,0,num_combo_cols-1);
21708 1 current_cpoollist=vbound(current_cpoollist,0,num_combo_cols-1);
21709 1 current_cautolist = vbound(current_cautolist, 0, num_combo_cols - 1);
21710
21711 //Generate bitmaps
21712 1 init_bitmap(&mapscreenbmp,16*(showedges?18:16),16*(showedges?13:11));
21713 1 init_bitmap(&brushbmp,256*mapscreen_screenunit_scale,176*mapscreen_screenunit_scale);
21714 1 init_bitmap(&brushscreen,(256+(showedges?16:0))*mapscreen_screenunit_scale,(176+(showedges?16:0))*mapscreen_screenunit_scale);
21715
21716 1 init_bitmap(&screen2,zq_screen_w,zq_screen_h);
21717
21718 1 center_zq_class_dialogs();
21719 1 center_zq_files_dialogs();
21720 1 center_zq_subscreen_dialogs();
21721 1 center_zq_tiles_dialogs();
21722 1 center_zquest_dialogs();
21723
21724 1 aspect_ratio = zq_screen_h / double(zq_screen_w);
21725
21726 1 mmap_init();
21727 1 }
21728
21729 11 void remove_locked_params_on_exit()
21730 {
21731 11 al_trace("Removing timers. \n");
21732 11 remove_int(fps_callback);
21733 11 remove_int(dclick_check);
21734 11 }
21735
21736 11 void destroy_bitmaps_on_exit()
21737 {
21738 11 al_trace("Cleaning bitmaps...");
21739 11 destroy_bitmap(screen2);
21740 11 destroy_bitmap(mapscreenbmp);
21741 11 destroy_bitmap(dmapbmp_small);
21742 11 destroy_bitmap(dmapbmp_large);
21743 11 destroy_bitmap(brushbmp);
21744 11 destroy_bitmap(brushscreen);
21745 11 al_trace("...");
21746
21747
2/2
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 11 times.
539 for(int32_t i=0; i<MOUSE_BMP_MAX*4; i++)
21748 {
21749 528 destroy_bitmap(mouse_bmp[i/4][i%4]);
21750 528 destroy_bitmap(mouse_bmp_1x[i/4][i%4]);
21751 528 }
21752
21753
2/2
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 11 times.
363 for(int32_t i=0; i<ICON_BMP_MAX*4; i++)
21754 352 destroy_bitmap(icon_bmp[i/4][i%4]);
21755
21756
2/2
✓ Branch 0 taken 704 times.
✓ Branch 1 taken 11 times.
715 for(int32_t i=0; i<16*4; i++)
21757 704 destroy_bitmap(flag_bmp[i/4][i%4]);
21758
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 11 times.
33 for(int32_t i=0; i<2; i++)
21759 22 destroy_bitmap(select_bmp[i]);
21760
21761
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 11 times.
99 for(int32_t i=0; i<MAXARROWS; i++)
21762 88 destroy_bitmap(arrow_bmp[i]);
21763
21764 11 al_trace(" OK. \n");
21765 11 }
21766
21767
21768 11 void quit_game()
21769 {
21770 11 set_last_timed_save(nullptr);
21771 11 save_config_file();
21772 11 zc_set_palette(black_palette);
21773 11 zc_stop_midi();
21774
21775 11 remove_locked_params_on_exit();
21776
21777 11 al_trace("Cleaning sfx. \n");
21778
21779
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 11 times.
2827 for(int32_t i=0; i<WAV_COUNT; i++)
21780 {
21781
2/2
✓ Branch 0 taken 2805 times.
✓ Branch 1 taken 11 times.
2816 if(customsfxdata[i].data!=NULL)
21782 {
21783 // delete [] customsfxdata[i].data;
21784 2805 free(customsfxdata[i].data);
21785 2805 }
21786
21787
1/2
✓ Branch 0 taken 2816 times.
✗ Branch 1 not taken.
2816 delete [] sfx_string[i];
21788 2816 }
21789
21790
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 11 times.
2827 for(int32_t i=0; i<MAXWPNS; i++)
21791 {
21792
1/2
✓ Branch 0 taken 2816 times.
✗ Branch 1 not taken.
2816 delete [] weapon_string[i];
21793 2816 }
21794
21795
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 11 times.
2827 for(int32_t i=0; i<MAXITEMS; i++)
21796 {
21797
1/2
✓ Branch 0 taken 2816 times.
✗ Branch 1 not taken.
2816 delete [] item_string[i];
21798 2816 }
21799
21800
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 11 times.
5643 for(int32_t i=0; i<eMAXGUYS; i++)
21801 {
21802
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 delete [] guy_string[i];
21803 5632 }
21804
21805 11 al_trace("Cleaning script buffer. \n");
21806
21807
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 11 times.
5643 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
21808 {
21809
2/4
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5632 times.
5632 if(ffscripts[i]!=NULL) delete ffscripts[i];
21810 5632 }
21811
21812
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 11 times.
2827 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
21813 {
21814
2/4
✓ Branch 0 taken 2816 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2816 times.
2816 if(itemscripts[i]!=NULL) delete itemscripts[i];
21815 2816 }
21816
21817
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 11 times.
2827 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
21818 {
21819
2/4
✓ Branch 0 taken 2816 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2816 times.
2816 if(guyscripts[i]!=NULL) delete guyscripts[i];
21820 2816 }
21821
21822
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 11 times.
2827 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
21823 {
21824
2/4
✓ Branch 0 taken 2816 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2816 times.
2816 if(lwpnscripts[i]!=NULL) delete lwpnscripts[i];
21825 2816 }
21826
21827
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 11 times.
2827 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
21828 {
21829
2/4
✓ Branch 0 taken 2816 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2816 times.
2816 if(ewpnscripts[i]!=NULL) delete ewpnscripts[i];
21830 2816 }
21831
21832
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 11 times.
2827 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
21833 {
21834
2/4
✓ Branch 0 taken 2816 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2816 times.
2816 if(screenscripts[i]!=NULL) delete screenscripts[i];
21835 2816 }
21836
21837
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 11 times.
44 for(int32_t i=0; i<3; i++) //should this be NUMSCRIPTGLOBAL or NUMSCRIPTGLOBALOLD? -Z
21838 {
21839
2/4
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
33 if(globalscripts[i]!=NULL) delete globalscripts[i];
21840 33 }
21841
21842
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 11 times.
66 for(int32_t i=0; i<NUMSCRIPTHERO; i++)
21843 {
21844
2/4
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 55 times.
55 if(playerscripts[i]!=NULL) delete playerscripts[i];
21845 55 }
21846
21847
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 11 times.
2827 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
21848 {
21849
2/4
✓ Branch 0 taken 2816 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2816 times.
2816 if(dmapscripts[i]!=NULL) delete dmapscripts[i];
21850 2816 }
21851
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 11 times.
2827 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
21852 {
21853
2/4
✓ Branch 0 taken 2816 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2816 times.
2816 if(itemspritescripts[i]!=NULL) delete itemspritescripts[i];
21854 2816 }
21855
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 11 times.
5643 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
21856 {
21857
2/4
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5632 times.
5632 if(comboscripts[i]!=NULL) delete comboscripts[i];
21858 5632 }
21859
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2816 times.
2827 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN; i++)
21860 {
21861
2/4
✓ Branch 0 taken 2816 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2816 times.
2816 if(subscreenscripts[i]!=NULL) delete subscreenscripts[i];
21862 2816 }
21863
21864 11 al_trace("Cleaning qst buffers. \n");
21865 11 del_qst_buffers();
21866
21867
21868 11 al_trace("Cleaning midis. \n");
21869
21870
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(customtunes)
21871 {
21872
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 11 times.
2827 for(int32_t i=0; i<MAXCUSTOMMIDIS_ZQ; i++)
21873 2816 customtunes[i].reset();
21874
21875 11 free(customtunes);
21876 11 }
21877
21878 11 al_trace("Cleaning undotilebuf. \n");
21879
21880 11 undocombobuf.clear();
21881
21882
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(newundotilebuf)
21883 {
21884
2/2
✓ Branch 0 taken 2359500 times.
✓ Branch 1 taken 11 times.
2359511 for(int32_t i=0; i<NEWMAXTILES; i++)
21885
1/2
✓ Branch 0 taken 2359500 times.
✗ Branch 1 not taken.
2359500 if(newundotilebuf[i].data) free(newundotilebuf[i].data);
21886
21887 11 free(newundotilebuf);
21888 11 }
21889
21890
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(filepath) free(filepath);
21891
21892
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(datapath) free(datapath);
21893
21894
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(midipath) free(midipath);
21895
21896
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(imagepath) free(imagepath);
21897
21898
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(tmusicpath) free(tmusicpath);
21899
21900
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(last_timed_save) free(last_timed_save);
21901
21902 11 destroy_bitmaps_on_exit();
21903 11 }
21904
21905 void quit_game2()
21906 {
21907 set_last_timed_save(nullptr);
21908 save_config_file();
21909 zc_set_palette(black_palette);
21910 zc_stop_midi();
21911
21912 remove_locked_params_on_exit();
21913
21914 al_trace("Cleaning sfx. \n");
21915
21916 for(int32_t i=0; i<WAV_COUNT; i++)
21917 {
21918 if(customsfxdata[i].data!=NULL)
21919 {
21920 // delete [] customsfxdata[i].data;
21921 free(customsfxdata[i].data);
21922 }
21923
21924 delete [] sfx_string[i];
21925 }
21926
21927 for(int32_t i=0; i<MAXWPNS; i++)
21928 {
21929 delete [] weapon_string[i];
21930 }
21931
21932 for(int32_t i=0; i<MAXITEMS; i++)
21933 {
21934 delete [] item_string[i];
21935 }
21936
21937 for(int32_t i=0; i<eMAXGUYS; i++)
21938 {
21939 delete [] guy_string[i];
21940 }
21941
21942 al_trace("Cleaning script buffer. \n");
21943
21944 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
21945 {
21946 if(ffscripts[i]!=NULL) delete ffscripts[i];
21947 }
21948
21949 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
21950 {
21951 if(itemscripts[i]!=NULL) delete itemscripts[i];
21952 }
21953
21954 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
21955 {
21956 if(guyscripts[i]!=NULL) delete guyscripts[i];
21957 }
21958
21959 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
21960 {
21961 if(lwpnscripts[i]!=NULL) delete lwpnscripts[i];
21962 }
21963
21964 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
21965 {
21966 if(ewpnscripts[i]!=NULL) delete ewpnscripts[i];
21967 }
21968
21969 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
21970 {
21971 if(screenscripts[i]!=NULL) delete screenscripts[i];
21972 }
21973
21974 for(int32_t i=0; i<3; i++) //should this be NUMSCRIPTGLOBAL or NUMSCRIPTGLOBALOLD? -Z
21975 {
21976 if(globalscripts[i]!=NULL) delete globalscripts[i];
21977 }
21978
21979 for(int32_t i=0; i<NUMSCRIPTHERO; i++)
21980 {
21981 if(playerscripts[i]!=NULL) delete playerscripts[i];
21982 }
21983
21984 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
21985 {
21986 if(dmapscripts[i]!=NULL) delete dmapscripts[i];
21987 }
21988 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
21989 {
21990 if(itemspritescripts[i]!=NULL) delete itemspritescripts[i];
21991 }
21992 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
21993 {
21994 if(comboscripts[i]!=NULL) delete comboscripts[i];
21995 }
21996 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN; i++)
21997 {
21998 if(subscreenscripts[i]!=NULL) delete subscreenscripts[i];
21999 }
22000
22001 al_trace("Cleaning qst buffers. \n");
22002 del_qst_buffers();
22003
22004
22005 al_trace("Cleaning midis. \n");
22006
22007 if(customtunes)
22008 {
22009 for(int32_t i=0; i<MAXCUSTOMMIDIS_ZQ; i++)
22010 customtunes[i].reset();
22011
22012 free(customtunes);
22013 }
22014
22015 al_trace("Cleaning undotilebuf. \n");
22016
22017 undocombobuf.clear();
22018
22019 if(newundotilebuf)
22020 {
22021 for(int32_t i=0; i<NEWMAXTILES; i++)
22022 if(newundotilebuf[i].data) free(newundotilebuf[i].data);
22023
22024 free(newundotilebuf);
22025 }
22026
22027 if(filepath) free(filepath);
22028
22029 if(datapath) free(datapath);
22030
22031 if(midipath) free(midipath);
22032
22033 if(imagepath) free(imagepath);
22034
22035 if(tmusicpath) free(tmusicpath);
22036
22037 if(last_timed_save) free(last_timed_save);
22038 }
22039
22040 1 void center_zquest_dialogs()
22041 {
22042 1 jwin_center_dialog(assignscript_dlg);
22043 1 center_zq_cset_dialogs();
22044 1 jwin_center_dialog(change_track_dlg);
22045 1 jwin_center_dialog(csetfix_dlg);
22046 1 center_zq_door_dialogs();
22047 1 jwin_center_dialog(editcomboa_dlg);
22048 1 jwin_center_dialog(editinfo_dlg);
22049 1 jwin_center_dialog(editshop_dlg);
22050 1 jwin_center_dialog(getnum_dlg);
22051 1 jwin_center_dialog(list_dlg);
22052 1 jwin_center_dialog(loadmap_dlg);
22053 1 jwin_center_dialog(misccolors_dlg);
22054 1 jwin_center_dialog(newcomboa_dlg);
22055 1 jwin_center_dialog(orgcomboa_dlg);
22056 1 jwin_center_dialog(path_dlg);
22057 1 jwin_center_dialog(screen_pal_dlg);
22058 1 jwin_center_dialog(secret_dlg);
22059 1 jwin_center_dialog(showpal_dlg);
22060 1 jwin_center_dialog(strlist_dlg);
22061 1 jwin_center_dialog(template_dlg);
22062 1 jwin_center_dialog(tp_dlg);
22063 1 jwin_center_dialog(tilewarp_dlg);
22064 1 jwin_center_dialog(sidewarp_dlg);
22065 1 jwin_center_dialog(warpring_dlg);
22066 1 center_zscript_dialogs();
22067 1 }
22068
22069
22070 void animate_coords()
22071 {
22072 coord_frame=(coord_timer>>3)&3;
22073
22074 if(++coord_timer>=(1<<5))
22075 {
22076 coord_timer=0;
22077 }
22078 }
22079
22080 static const char *help_list[] =
22081 {
22082 "PREVIEW MODE",
22083 "PgUp/PgDn - Scroll through hotkey list",
22084 "Esc/Enter - Exit Preview Mode",
22085 "R - Restore screen to original state",
22086 "C - Toggle combo cycling On/Off",
22087 "S - Trigger screen secrets",
22088 "Q/W/F - These still work",
22089 "P - Pause everything",
22090 "A - Advance frame-by-frame",
22091 "1-4 - Trigger tile warp A-D",
22092 "5-8 - Trigger side warp A-D",
22093 "9 - Enable timed warps",
22094 "",
22095 "",
22096 };
22097
22098 void do_previewtext()
22099 {
22100 FONT* oldfont = font;
22101 font = get_zc_font(font_lfont_l);
22102
22103 //Put in help areas
22104 auto& sqr = preview_text;
22105 int ind = 0, len = 0;
22106 for(int q = 0; q < 12; ++q)
22107 {
22108 int l = text_length(font, help_list[q]);
22109 if(len < l) len = l;
22110 }
22111 sqr.xscale = len+2;
22112 sqr.yscale = text_height(font);
22113 for(int col = 0; col < sqr.w; ++col)
22114 {
22115 for(int row = 0; row < sqr.h; ++row)
22116 {
22117 auto& line = sqr.subsquare(col,row);
22118 textprintf_ex(screen,font,line.x,line.y,jwin_pal[jcTEXTFG],-1,"%s",help_list[ind++]);
22119 }
22120 }
22121
22122 font = oldfont;
22123 }
22124
22125
22126 bool reload_fonts = false;
22127 void run_zq_frame()
22128 {
22129 if(reload_fonts)
22130 {
22131 init_custom_fonts();
22132 load_size_poses();
22133 reload_fonts = false;
22134 }
22135
22136 handlePreviewMode();
22137 domouse();
22138 get_screen_rti()->freeze = false;
22139 custom_vsync();
22140 refresh(rCLEAR|rALL);
22141 }
22142 1 int32_t d_nbmenu_proc(int32_t msg,DIALOG *d,int32_t c)
22143 {
22144
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
1 switch(msg)
22145 {
22146 case MSG_VSYNC:
22147 run_zq_frame();
22148 break;
22149 case MSG_GOTMOUSE:
22150 case MSG_XCHAR:
22151 ComboBrushPause=1;
22152 refresh(rMAP);
22153 ComboBrushPause=0;
22154 clear_tooltip();
22155 break;
22156 }
22157
22158 1 return GuiMenu::proc(msg,d,c);
22159 }
22160
22161 bool prv_press=false;
22162
22163 void dopreview()
22164 {
22165 refresh(rMAP);
22166
22167 while(!(gui_mouse_b()))
22168 {
22169 if(keypressed())
22170 {
22171 if(!prv_press)
22172 {
22173 prv_press=true;
22174
22175 switch(readkey()>>8)
22176 {
22177 case KEY_ESC:
22178 case KEY_ENTER:
22179 case KEY_ENTER_PAD:
22180 goto finished;
22181 break;
22182
22183 case KEY_F:
22184 Flags^=cFLAGS;
22185 refresh(rMAP);
22186 break;
22187
22188 case KEY_R:
22189 onReloadPreview();
22190 break;
22191
22192 case KEY_S:
22193 onSecretsPreview();
22194 break;
22195
22196 case KEY_C:
22197 onCopy();
22198 break;
22199
22200 case KEY_A:
22201 onAKey();
22202 break;
22203
22204 case KEY_P:
22205 onP();
22206 break;
22207
22208 case KEY_L:
22209 onShowDarkness();
22210 break;
22211
22212 case KEY_1:
22213 Map.prv_dowarp(0,0);
22214 prv_warp=0;
22215 break;
22216
22217 case KEY_2:
22218 Map.prv_dowarp(0,1);
22219 prv_warp=0;
22220 break;
22221
22222 case KEY_3:
22223 Map.prv_dowarp(0,2);
22224 prv_warp=0;
22225 break;
22226
22227 case KEY_4:
22228 Map.prv_dowarp(0,3);
22229 prv_warp=0;
22230 break;
22231
22232 case KEY_5:
22233 Map.prv_dowarp(1,0);
22234 prv_warp=0;
22235 break;
22236
22237 case KEY_6:
22238 Map.prv_dowarp(1,1);
22239 prv_warp=0;
22240 break;
22241
22242 case KEY_7:
22243 Map.prv_dowarp(1,2);
22244 prv_warp=0;
22245 break;
22246
22247 case KEY_8:
22248 Map.prv_dowarp(1,3);
22249 prv_warp=0;
22250 break;
22251
22252 case KEY_9:
22253 if(prv_twon)
22254 {
22255 prv_twon=0;
22256 Map.set_prvtime(0);
22257 prv_warp=0;
22258 }
22259 else
22260 {
22261 Map.set_prvtime(Map.get_prvscr()->timedwarptics);
22262 prv_twon=1;
22263 }
22264
22265 break;
22266
22267 case KEY_W:
22268 onShowWalkability();
22269 break;
22270
22271 case KEY_Q:
22272 onShowComboInfoCSet();
22273 break;
22274 }
22275 }
22276 else
22277 {
22278 readkey();
22279 }
22280 }
22281 else
22282 {
22283 prv_press=false;
22284 }
22285
22286 if(prv_warp)
22287 {
22288 Map.prv_dowarp(1,0);
22289 prv_warp=0;
22290 }
22291
22292 if(Map.get_prvfreeze())
22293 {
22294 if(Map.get_prvadvance())
22295 {
22296 custom_vsync();
22297 Map.set_prvadvance(0);
22298 }
22299 }
22300 else
22301 {
22302 custom_vsync();
22303 Map.set_prvadvance(0);
22304 }
22305
22306 refresh(rALL);
22307 }
22308
22309 finished:
22310 //Flags=of;
22311 reset_combo_animations();
22312 reset_combo_animations2();
22313 MouseSprite::set(ZQM_NORMAL);
22314 prv_mode=0;
22315 prv_warp=0;
22316 Map.end_prv();
22317 Map.refresh_color();
22318 refresh(rMAP+rMENU);
22319
22320 while(gui_mouse_b())
22321 {
22322 /* do nothing */
22323 rest(1);
22324 }
22325 }
22326
22327 void call_vidmode_dlg();
22328 int32_t onZQVidMode()
22329 {
22330 call_vidmode_dlg();
22331 return D_O_K;
22332 }
22333
22334 bool screenIsScrolling()
22335 {
22336 return false;
22337 }
22338
22339 void write_includepaths()
22340 {
22341 FILE* f = fopen("includepaths.txt", "w");
22342 if(f)
22343 {
22344 fwrite(FFCore.includePathString,1,strlen(FFCore.includePathString),f);
22345 fclose(f);
22346 }
22347 }
22348
22349 11 int32_t save_config_file()
22350 {
22351
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if (!application_has_loaded) return 0;
22352
22353 char qtnametitle[20];
22354 char qtpathtitle[20];
22355 char *datapath2=(char *)malloc(2048);
22356 char *midipath2=(char *)malloc(2048);
22357 char *imagepath2=(char *)malloc(2048);
22358 char *tmusicpath2=(char *)malloc(2048);
22359 strcpy(datapath2, datapath);
22360 strcpy(midipath2, midipath);
22361 strcpy(imagepath2, imagepath);
22362 strcpy(tmusicpath2, tmusicpath);
22363 chop_path(datapath2);
22364 chop_path(midipath2);
22365 chop_path(imagepath2);
22366 chop_path(tmusicpath2);
22367 write_includepaths();
22368
22369 zc_set_config("zquest",data_path_name,datapath2);
22370 zc_set_config("zquest",midi_path_name,midipath2);
22371 zc_set_config("zquest",image_path_name,imagepath2);
22372 zc_set_config("zquest",tmusic_path_name,tmusicpath2);
22373
22374 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
22375 {
22376 window_width = al_get_display_width(all_get_display());
22377 window_height = al_get_display_height(all_get_display());
22378 zc_set_config("zquest","window_width",window_width);
22379 zc_set_config("zquest","window_height",window_height);
22380 }
22381 if (all_get_display() && !all_get_fullscreen_flag() && SaveWinPos)
22382 {
22383 int o_window_x, o_window_y;
22384 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
22385 zc_set_config("zquest", "window_x", o_window_x);
22386 zc_set_config("zquest", "window_y", o_window_y);
22387 }
22388
22389 byte b = 0;
22390 for(int32_t x=0; x<7; x++)
22391 {
22392 set_bit(&b,x,LayerMaskInt[x]);
22393 }
22394
22395 zc_set_config("zquest","layer_mask",b);
22396
22397 flush_config_file();
22398 #ifdef __EMSCRIPTEN__
22399 em_sync_fs();
22400 #endif
22401 free(datapath2);
22402 free(midipath2);
22403 free(imagepath2);
22404 free(tmusicpath2);
22405 return 0;
22406 11 }
22407
22408 int32_t d_timer_proc(int32_t msg, DIALOG *d, int32_t c)
22409 {
22410 //these are here to bypass compiler warnings about unused arguments
22411 c=c;
22412 d=d;
22413
22414 switch(msg)
22415 {
22416 case MSG_IDLE:
22417 #ifdef _WIN32
22418 if(zqUseWin32Proc != FALSE)
22419 win32data.Update(Frameskip); //experimental win32 fixes
22420
22421 #endif
22422
22423 // This has been crashing on Windows, and it saves plenty without it
22424 //check_autosave();
22425 break;
22426 }
22427
22428 return D_O_K;
22429 }
22430
22431 void check_autosave()
22432 {
22433 if (!first_save)
22434 return;
22435
22436 if(AutoSaveInterval>0)
22437 {
22438 time(&auto_save_time_current);
22439 auto_save_time_diff = difftime(auto_save_time_current,auto_save_time_start);
22440
22441 if(auto_save_time_diff>AutoSaveInterval*60)
22442 {
22443 if (!autosaved)
22444 {
22445 MouseSprite::set(ZQM_NORMAL);
22446 replace_extension(last_timed_save, filepath, "qt0", 2047);
22447 set_last_timed_save(last_timed_save);
22448
22449 if((header.zelda_version != ZELDA_VERSION || header.build != VERSION_BUILD))
22450 {
22451 jwin_alert("Auto Save","This quest was saved in an older version of ZQuest.","If you wish to use the autosave feature, you must manually","save the files in this version first.","OK",NULL,13,27,get_zc_font(font_lfont));
22452 time(&auto_save_time_start);
22453 return;
22454 }
22455
22456 int32_t ret = save_quest(last_timed_save, true);
22457
22458 if(ret)
22459 {
22460 jwin_alert("Error","Timed save did not complete successfully.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
22461 set_last_timed_save(nullptr);
22462 }
22463 else autosaved = true;
22464
22465 save_config_file();
22466 }
22467 time(&auto_save_time_start);
22468 }
22469 }
22470 }
22471
22472 void flushItemCache(bool) {}
22473 void ringcolor(bool forceDefault)
22474 {
22475 forceDefault=forceDefault;
22476 }
22477
22478 bool item_disabled(int32_t)
22479 {
22480 return false;
22481 }
22482
22483 int32_t onCmdExit()
22484 {
22485 // replaces onExit for the -large button command "Exit"
22486 close_button_quit = true;
22487 return 0;
22488 }
22489
22490 int32_t onQuickCompile()
22491 {
22492 if(do_compile_and_slots(1,false))
22493 {
22494 mark_save_dirty();
22495 InfoDialog("Quick Compile","Success!").show();
22496 }
22497 else
22498 {
22499 InfoDialog("Quick Compile","Failure!").show();
22500 }
22501 return 0;
22502 }
22503 int32_t onSmartCompile()
22504 {
22505 if(do_compile_and_slots(2,false))
22506 {
22507 mark_save_dirty();
22508 InfoDialog("Smart Compile","Success!").show();
22509 }
22510 else
22511 {
22512 InfoDialog("Smart Compile","Failure!").show();
22513 }
22514 return 0;
22515 }
22516
22517 int32_t strchrnum(char const* str, char c)
22518 {
22519 for(int32_t i=0; str[i]; ++i)
22520 {
22521 if(str[i]==c)
22522 {
22523 return i;
22524 }
22525 }
22526
22527 return -1;
22528 }
22529
22530 int32_t get_longest_line_length(FONT *f, char* str)
22531 {
22532 int32_t maxlen=0;
22533 char* tmpstr = str;
22534 char temp=0;
22535 int32_t t=0;
22536 int32_t new_t=-1;
22537 while(tmpstr[0])
22538 {
22539 t=strchrnum(tmpstr, '\n');
22540
22541 if(t==-1)
22542 {
22543 t=(int32_t)strlen(tmpstr);
22544 }
22545
22546 if((uint32_t)t!=strlen(tmpstr))
22547 {
22548 new_t=t+1;
22549 }
22550 else
22551 {
22552 new_t=-1;
22553 }
22554
22555 temp = tmpstr[t];
22556 tmpstr[t]=0;
22557 maxlen=zc_max(maxlen,text_length(f, tmpstr));
22558 tmpstr[t]=temp;
22559
22560 if(new_t!=-1)
22561 {
22562 tmpstr+=new_t;
22563 }
22564 else break;
22565 }
22566 return maxlen;
22567 }
22568
22569 int32_t count_lines(char const* str)
22570 {
22571 int32_t count=1;
22572
22573 for(word i=0; i<strlen(str); ++i)
22574 {
22575 if(str[i]=='\n')
22576 {
22577 ++count;
22578 }
22579 }
22580
22581 return count;
22582 }
22583
22584 void textbox_out(BITMAP* dest, FONT* font, int x, int y, int fg, int bg, char const* str, int align, size_and_pos* dims)
22585 {
22586 static size_and_pos nilsz;
22587 size_and_pos& txbox = dims ? *dims : nilsz;
22588
22589 char* kill = (char*)malloc(strlen(str)+1);
22590 char *tmpstr = kill;
22591 strcpy(tmpstr,str);
22592
22593 while(tmpstr[0] == '\n')
22594 ++tmpstr;
22595 int len = strlen(tmpstr);
22596 while(tmpstr[len-1] == '\n')
22597 tmpstr[--len] = 0;
22598
22599 txbox.x=x;
22600 txbox.y=y;
22601 int32_t lines=count_lines(tmpstr);
22602 txbox.w = 1;
22603 txbox.h = lines;
22604 txbox.xscale = get_longest_line_length(font, tmpstr);
22605 txbox.yscale = text_height(font);
22606
22607 int ax = 0; //Aligned x
22608 switch(align)
22609 {
22610 case 0: //left
22611 break;
22612 case 1: //center
22613 txbox.x -= txbox.xscale/2;
22614 ax = txbox.xscale/2;
22615 break;
22616 case 2: //right
22617 txbox.x -= txbox.xscale;
22618 ax = txbox.xscale;
22619 break;
22620 }
22621
22622 int bw = txbox.w*txbox.xscale;
22623 int bh = txbox.h*txbox.yscale;
22624 BITMAP* outbmp = create_bitmap_ex(8, bw, bh);
22625 clear_to_color(outbmp, bg);
22626
22627 char temp = 0;
22628 int32_t t=0;
22629 int32_t new_t=-1;
22630 int32_t line=0;
22631
22632 while(tmpstr[t])
22633 {
22634 t=strchrnum(tmpstr, '\n');
22635
22636 if(t==-1)
22637 t=(int32_t)strlen(tmpstr);
22638
22639 if((uint32_t)t!=strlen(tmpstr))
22640 new_t=t+1;
22641 else
22642 new_t=-1;
22643
22644 temp = tmpstr[t];
22645 tmpstr[t]=0;
22646 gui_textout_ln(outbmp, font, (ucc*)tmpstr, ax, (line*txbox.yscale), fg, -1, align);
22647 tmpstr[t]=temp;
22648 ++line;
22649
22650 if(new_t!=-1)
22651 {
22652 tmpstr+=new_t;
22653 t=0;
22654 }
22655 }
22656
22657 blit(outbmp, dest, 0, 0, txbox.x, txbox.y, bw, bh);
22658 destroy_bitmap(outbmp);
22659 free(kill);
22660 }
22661
22662 void highlight_sqr(BITMAP* dest, int color, int x, int y, int w, int h, int thick)
22663 {
22664 for(int q = 0; q < thick; ++q)
22665 {
22666 safe_rect(dest, x+q, y+q, x+w-1-q, y+h-1-q, color);
22667 }
22668 }
22669 void highlight_sqr(BITMAP* dest, int color, size_and_pos const& rec, int thick)
22670 {
22671 highlight_sqr(dest, color, rec.x, rec.y, rec.tw(), rec.th(), thick);
22672 }
22673 void highlight_frag(BITMAP* dest, int color, int x1, int y1, int w, int h, int fw, int fh, int thick)
22674 {
22675 int xc = x1+fw-1;
22676 int yc = y1+fh-1;
22677 int x2 = x1+w-1;
22678 int y2 = y1+h-1;
22679
22680 hline(dest, x1, y1, x2, color);
22681 vline(dest, x1, y1, y2, color);
22682
22683 hline(dest, x1, y2, xc, color);
22684 vline(dest, x2, y1, yc, color);
22685 hline(dest, xc, yc, x2, color);
22686 vline(dest, xc, yc, y2, color);
22687 }
22688 void highlight_frag(BITMAP* dest, int color, size_and_pos const& rec, int thick)
22689 {
22690 highlight_frag(dest, color, rec.x, rec.y, rec.tw(), rec.th(), rec.fw, rec.fh, thick);
22691 }
22692
22693 void highlight(BITMAP* dest, size_and_pos& hl)
22694 {
22695 if(hl.fw > -1 && hl.fh > -1)
22696 {
22697 highlight_frag(dest, hl.data[1], hl, hl.data[0]);
22698 }
22699 else highlight_sqr(dest, hl.data[1], hl, hl.data[0]);
22700 }
22701
22702 std::pair<int, int> get_box_text_size(char const* tipmsg, double txscale)
22703 {
22704 if(txscale < 1) txscale = 1;
22705 char* kill = (char*)malloc(strlen(tipmsg)+1);
22706 char *tmpstr = kill;
22707 strcpy(tmpstr,tipmsg);
22708
22709 while(tmpstr[0] == '\n')
22710 ++tmpstr;
22711 int len = strlen(tmpstr);
22712 while(tmpstr[len-1] == '\n')
22713 tmpstr[--len] = 0;
22714
22715 int32_t lines = count_lines(tmpstr);
22716 int txlen = get_longest_line_length(font, tmpstr);
22717 int txhei = lines*text_height(font);
22718 int tx_sclen = (txlen * txscale);
22719 int tx_schei = (txhei * txscale);
22720 int w = tx_sclen + 8 + 1;
22721 int h = tx_schei + 8 + 1;
22722 if (w > zq_screen_w)
22723 w = zq_screen_w;
22724 if (h > zq_screen_h)
22725 h = zq_screen_h;
22726 return {w, h};
22727 }
22728
22729 void draw_box(BITMAP* destbmp, size_and_pos* pos, char const* tipmsg, double txscale)
22730 {
22731 if(txscale < 1) txscale = 1;
22732 char* kill = (char*)malloc(strlen(tipmsg)+1);
22733 char *tmpstr = kill;
22734 strcpy(tmpstr,tipmsg);
22735
22736 while(tmpstr[0] == '\n')
22737 ++tmpstr;
22738 int len = strlen(tmpstr);
22739 while(tmpstr[len-1] == '\n')
22740 tmpstr[--len] = 0;
22741
22742 auto& box = *pos;
22743 clear_bitmap(destbmp);
22744
22745 int32_t lines=count_lines(tmpstr);
22746 int txlen = get_longest_line_length(font, tmpstr);
22747 int txhei = lines*text_height(font);
22748 int tx_sclen = (txlen * txscale);
22749 int tx_schei = (txhei * txscale);
22750 box.w = tx_sclen + 8 + 1;
22751 box.h = tx_schei + 8 + 1;
22752 if (box.w > zq_screen_w)
22753 box.w = zq_screen_w;
22754 if (box.h > zq_screen_h)
22755 box.h = zq_screen_h;
22756
22757 if(box.x+box.w>=zq_screen_w)
22758 {
22759 box.x=(zq_screen_w - box.w);
22760 }
22761
22762 if(box.y+box.h>=zq_screen_h)
22763 {
22764 box.y=(zq_screen_h - box.h);
22765 }
22766
22767 rectfill(destbmp, 1, 1, box.w-3, box.h-3, jwin_pal[jcTEXTBG]);
22768 rect(destbmp, 0, 0, box.w-2, box.h-2, jwin_pal[jcTEXTFG]);
22769 vline(destbmp, box.w-1, 0, box.h-1, jwin_pal[jcTEXTFG]);
22770 hline(destbmp, 1, box.h-1, box.w-2, jwin_pal[jcTEXTFG]);
22771 destbmp->line[box.h-1][0]=0;
22772 destbmp->line[0][box.w-1]=0;
22773
22774 char temp = 0;
22775 int32_t t=0;
22776 int32_t new_t=-1;
22777 int32_t line=0;
22778
22779 BITMAP* txbmp = create_bitmap_ex(8,box.w,box.h);
22780 clear_bitmap(txbmp);
22781 while(tmpstr[t])
22782 {
22783 t=strchrnum(tmpstr, '\n');
22784
22785 if(t==-1)
22786 {
22787 t=(int32_t)strlen(tmpstr);
22788 }
22789
22790 if((uint32_t)t!=strlen(tmpstr))
22791 {
22792 new_t=t+1;
22793 }
22794 else
22795 {
22796 new_t=-1;
22797 }
22798
22799 temp = tmpstr[t];
22800 tmpstr[t]=0;
22801 textprintf_ex(txbmp, font, 0, (line*text_height(font)), jwin_pal[jcTEXTFG], -1, "%s", tmpstr);
22802 tmpstr[t]=temp;
22803 ++line;
22804
22805 if(new_t!=-1)
22806 {
22807 tmpstr+=new_t;
22808 t=0;
22809 }
22810 }
22811 masked_stretch_blit(txbmp,destbmp,0,0,txlen,txhei,4,4,tx_sclen,tx_schei);
22812 destroy_bitmap(txbmp);
22813 free(kill);
22814 }
22815
22816 void update_tooltip(int32_t x, int32_t y, size_and_pos const& sqr, char const* tipmsg, double scale)
22817 {
22818 update_tooltip(x,y,sqr.x,sqr.y,sqr.w*sqr.xscale,sqr.h*sqr.yscale,tipmsg,sqr.fw,sqr.fh,scale);
22819 }
22820 void update_tooltip(int32_t x, int32_t y, int32_t tx, int32_t ty, int32_t tw, int32_t th, char const* tipmsg, int fw, int fh, double scale)
22821 {
22822 if(!EnableTooltips)
22823 {
22824 return;
22825 }
22826
22827 ttip_install(ttip_global_id, tipmsg, tx, ty, tw, th, x, y, fw, fh);
22828 }
22829
22830 void ZQ_ClearQuestPath()
22831 {
22832 zc_set_config("zquest","win_last_quest",(char const*)nullptr);
22833 strcpy(filepath,"");
22834 }
22835
22836 //FFCore
22837
22838 void FFScript::init()
22839 {
22840 for ( int32_t q = 0; q < wexLast; q++ ) warpex[q] = 0;
22841 numscriptdraws = 0;
22842 max_ff_rules = qr_MAX;
22843 temp_no_stepforward = 0;
22844 nostepforward = 0;
22845
22846 coreflags = 0;
22847 skip_ending_credits = 0;
22848 music_update_cond = 0;
22849 music_update_flags = 0;
22850 for ( int32_t q = 0; q < susptLAST; q++ ) { system_suspend[q] = false; }
22851
22852 //for ( int32_t q = 0; q < 512; q++ ) FF_rules[q] = 0;
22853 int32_t usr_midi_volume = usr_digi_volume = usr_sfx_volume = usr_music_volume = usr_panstyle = 0;
22854 FF_hero_action = 0;
22855 enemy_removal_point[spriteremovalY1] = -32767;
22856 enemy_removal_point[spriteremovalY2] = 32767;
22857 enemy_removal_point[spriteremovalX1] = -32767;
22858 enemy_removal_point[spriteremovalX2] = 32767;
22859 enemy_removal_point[spriteremovalZ1] = -32767;
22860 enemy_removal_point[spriteremovalZ2] = 32767;
22861
22862 for ( int32_t q = 0; q < 4; q++ )
22863 {
22864 FF_screenbounds[q] = 0;
22865 FF_screen_dimensions[q] = 0;
22866 FF_subscreen_dimensions[q] = 0;
22867 FF_eweapon_removal_bounds[q] = 0;
22868 FF_lweapon_removal_bounds[q] = 0;
22869 }
22870 for ( int32_t q = 0; q < FFSCRIPTCLASS_CLOCKS; q++ )
22871 {
22872 FF_clocks[q] = 0;
22873 }
22874 for ( int32_t q = 0; q < SCRIPT_DRAWING_RULES; q++ )
22875 {
22876 ScriptDrawingRules[q] = 0;
22877 }
22878 for ( int32_t q = 0; q < NUM_USER_MIDI_OVERRIDES; q++ )
22879 {
22880 FF_UserMidis[q] = 0;
22881 }
22882 subscreen_scroll_speed = 0; //make a define for a default and read quest override! -Z
22883 kb_typing_mode = false;
22884 initIncludePaths();
22885 }
22886
22887 void FFScript::updateIncludePaths()
22888 {
22889 includePaths.clear();
22890 int32_t pos = 0; int32_t pathnumber = 0;
22891 for ( int32_t q = 0; includePathString[pos]; ++q )
22892 {
22893 int32_t dest = 0;
22894 char buf[2048] = {0};
22895 while(includePathString[pos] != ';' && includePathString[pos])
22896 {
22897 buf[dest] = includePathString[pos];
22898 ++pos;
22899 ++dest;
22900 }
22901 ++pos;
22902 string str(buf);
22903 includePaths.push_back(str);
22904 }
22905 }
22906
22907 void FFScript::initIncludePaths()
22908 {
22909 memset(includePathString,0,sizeof(includePathString));
22910 FILE* f = fopen("includepaths.txt", "r");
22911 if(f)
22912 {
22913 int32_t pos = 0;
22914 int32_t c;
22915 do
22916 {
22917 c = fgetc(f);
22918 if(c!=EOF)
22919 includePathString[pos++] = c;
22920 }
22921 while(c!=EOF && pos<MAX_INCLUDE_PATH_CHARS);
22922 if(pos<MAX_INCLUDE_PATH_CHARS)
22923 includePathString[pos] = '\0';
22924 includePathString[MAX_INCLUDE_PATH_CHARS-1] = '\0';
22925 fclose(f);
22926 }
22927 else strcpy(includePathString, "include/;headers/;scripts/;");
22928 al_trace("Full path string is: ");
22929 safe_al_trace(includePathString);
22930 al_trace("\n");
22931 updateIncludePaths();
22932
22933 for ( size_t q = 0; q < includePaths.size(); ++q )
22934 {
22935 al_trace("Include path %zu: ",q);
22936 safe_al_trace(includePaths.at(q).c_str());
22937 al_trace("\n");
22938 }
22939 }
22940
22941 int32_t FFScript::getQRBit(int32_t rule)
22942 {
22943 return ( get_qr(rule) ? 1 : 0 );
22944 }
22945
22946 int32_t FFScript::getTime(int32_t type)
22947 {
22948 //struct tm *tm_struct = localtime(time(NULL));
22949 struct tm * tm_struct;
22950 time_t rawtime;
22951 time (&rawtime);
22952 tm_struct = localtime (&rawtime);
22953
22954 switch(type)
22955 {
22956 case curyear:
22957 {
22958 int32_t year = tm_struct->tm_year + 1900; /* year */
22959 //year format starts at 1900, so we add it to the return
22960 return year;
22961
22962 }
22963 case curmonth:
22964 {
22965 int32_t month = tm_struct->tm_mon +1; /* month */
22966 //Months start at 0, but we want 1->12
22967 return month;
22968 }
22969 case curday_month:
22970 {
22971 int32_t day_month = tm_struct->tm_mday; /* day of the month */
22972 return day_month;
22973 }
22974 case curday_week:
22975 {
22976 int32_t day_week = tm_struct->tm_wday; /* day of the week */
22977 return day_week;
22978 }
22979 case curhour:
22980 {
22981 int32_t hour = tm_struct->tm_hour; /* hours */
22982 return hour;
22983 }
22984 case curminute:
22985 {
22986 int32_t minutes = tm_struct->tm_min; /* minutes */
22987 return minutes;
22988 }
22989 case cursecond:
22990 {
22991 int32_t secs = tm_struct->tm_sec; /* seconds */
22992 return secs;
22993 }
22994 case curdayyear:
22995 {
22996 int32_t day_year = tm_struct->tm_yday; /* day in the year */
22997 return day_year;
22998 }
22999 case curDST:
23000 {
23001 int32_t isDST = tm_struct->tm_isdst; /* daylight saving time */
23002 return isDST;
23003 }
23004 default: return -1;
23005
23006 }
23007 }
23008
23009 extern const char *itemclass_help_string_defaults[itype_max];
23010
23011 /* end */
23012
23013 24576 int32_t FFScript::getQuestHeaderInfo(int32_t type)
23014 {
23015 24576 return quest_format[type];
23016 }
23017
23018 bool isSideViewGravity(int32_t t)
23019 {
23020 return (Map.CurrScr()->flags7&fSIDEVIEW) != 0;
23021 }
23022
23023
23024
23025
23026 void FFScript::ZScriptConsole(bool open)
23027 {
23028
23029
23030 #ifdef _WIN32
23031 if ( console_is_open )
23032 {
23033 zscript_coloured_console.Create("ZQuest Classic Logging Console", 600, 200);
23034 zscript_coloured_console.cls(CConsoleLoggerEx::COLOR_BACKGROUND_BLACK);
23035 zscript_coloured_console.gotoxy(0,0);
23036 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
23037 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"ZQuest Classic Logging Console\n");
23038 }
23039 else
23040 {
23041 //close
23042 zscript_coloured_console.Close();
23043 }
23044 #endif
23045 }
23046
23047 template <typename ...Params>
23048 void FFScript::ZScriptConsole(int32_t attributes,const char *format, Params&&... params)
23049 {
23050 #ifdef _WIN32
23051 initConsole();
23052 zscript_coloured_console.cprintf( attributes, format, std::forward<Params>(params)... );
23053 #endif
23054 }
23055
23056 int32_t getpitfall(int32_t x, int32_t y){return 0;}
23057
23058 bool update_hw_pal = false;
23059 void update_hw_screen()
23060 {
23061 if (is_headless())
23062 return;
23063
23064 framecnt++;
23065
23066 zc_process_display_events();
23067 if (update_hw_pal)
23068 {
23069 zc_set_palette(RAMpal);
23070 update_hw_pal = false;
23071 }
23072
23073 render_timer_wait();
23074 render_zq();
23075 }
23076
23077 bool checkCost(int32_t ctr, int32_t amnt)
23078 {
23079 if(!game) return true;
23080 if(amnt <= 0) return true;
23081 switch (ctr)
23082 {
23083 case crMONEY: //rupees
23084 {
23085 if ( current_item_power(itype_wallet) ) return true;
23086 break;
23087 }
23088 case crMAGIC: //magic
23089 {
23090 if (get_qr(qr_ENABLEMAGIC))
23091 {
23092 return (((current_item_power(itype_magicring) > 0)
23093 ? game->get_maxmagic()
23094 : game->get_magic()+game->get_dmagic())>=amnt*game->get_magicdrainrate());
23095 }
23096 return true;
23097 }
23098 case crARROWS:
23099 {
23100 if(current_item_power(itype_quiver))
23101 return true;
23102 if(!get_qr(qr_TRUEARROWS))
23103 return checkCost(crMONEY, amnt);
23104 break;
23105 }
23106 case crBOMBS:
23107 {
23108 if(current_item_power(itype_bombbag))
23109 return true;
23110 break;
23111 }
23112 case crSBOMBS:
23113 {
23114 if(current_item_power(itype_bombbag)
23115 && itemsbuf[current_item_id(itype_bombbag)].flags & item_flag1)
23116 return true;
23117 break;
23118 }
23119 }
23120 return (game->get_counter(ctr)+game->get_dcounter(ctr)>=amnt);
23121 }
23122 bool checkmagiccost(int32_t itemid, bool checkTime)
23123 {
23124 if(itemid < 0)
23125 {
23126 return false;
23127 }
23128 itemdata const& id = itemsbuf[itemid];
23129 return checkCost(id.cost_counter[0], id.cost_amount[0])
23130 && checkCost(id.cost_counter[1], id.cost_amount[1]);
23131 }
23132 bool checkbunny(int32_t itemid)
23133 {
23134 return true;
23135 }
23136
23137 void payCost(int32_t ctr, int32_t amnt, int32_t tmr, bool ignoreTimer)
23138 {
23139 return;
23140 }
23141 void paymagiccost(int32_t itemid, bool ignoreTimer, bool onlyTimer)
23142 {
23143 return;
23144 }
23145 bool is_in_scrolling_region()
23146 {
23147 return false;
23148 }
23149
23150 void enter_sys_pal(){}
23151 void exit_sys_pal(){}
23152
23153 void replay_step_comment(std::string comment) {}
23154 bool replay_is_active() {return false;}
23155 9 bool replay_is_replaying() {return false;}
23156 bool replay_version_check(int min, int max) {return max == -1;}
23157 bool replay_is_debug() {return false;}
23158 std::string replay_get_meta_str(std::string key){return "";}
23159 int32_t item::run_script(int32_t mode){return 0;};
23160 ffcdata* slopes_getFFC(int id)
23161 {
23162 return nullptr;
23163 }
23164
23165 int calculate_test_dmap()
23166 {
23167 int dmap = -1;
23168 auto pal = Map.getcolor();
23169 int scr = Map.getCurrScr();
23170 int scrx = scr & 0x0F;
23171 for(auto q = 0; q < MAXDMAPS; ++q)
23172 {
23173 auto& dm = DMaps[q];
23174 if(dm.map != Map.getCurrMap())
23175 continue;
23176 if((dm.type&dmfTYPE)!=dmOVERW)
23177 {
23178 if(scrx < dm.xoff || scrx >= dm.xoff+8)
23179 continue;
23180 }
23181 if(dmap < 0)
23182 dmap = q; // soft-accept this, but look for better still
23183 if(pal == dm.color)
23184 {
23185 dmap = q;
23186 // found the best match we have information for, break out
23187 break;
23188 }
23189 }
23190 if(dmap < 0) dmap = 0;
23191 return dmap;
23192 }
23193
23194 #ifdef __EMSCRIPTEN__
23195 extern "C" void open_test_mode()
23196 {
23197 int dmap = calculate_test_dmap();
23198 int scr = zc_min(0x7F, Map.getCurrScr());
23199
23200 em_open_test_mode(filepath, dmap, scr, -1);
23201 }
23202
23203 extern "C" void get_shareable_url()
23204 {
23205 EM_ASM({
23206 ZC.setShareableUrl({open: UTF8ToString($0), map: $1, screen: $2});
23207 }, filepath, Map.getCurrMap(), Map.getCurrScr());
23208 }
23209 #endif
23210
23211 11 void setZScriptVersion(int32_t v){}
23212